2014-10-05 47 views
-1

目前,我正在学习Notepad Exercise 1在谷歌,这里是关于SQLite的部分代码:Android SQLite数据库删除方法,为什么返回的东西> 0?

/** 
* Delete the note with the given rowId 
* 
* @param rowId id of note to delete 
* @return true if deleted, false otherwise 
*/ 

// MDB是DatabaseHelper的实例与getWritableDatabase()

公共布尔deleteNote(长ROWID) {

 return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; 
    } 

似乎他们并没有提到为什么它的“> 0”的结尾,可以解释我?

回答

0

按照 docs:

如果whereClause传递在受影响的行0的数量,否则。删除所有行并获得一个计数传递“1”作为whereClause。

如果您没有得到至少1个,那么它不会删除它,所以它返回false否则返回true。

相关问题