我在android中从sqlite数据库中查询一些数据,但是从一些奇怪的原因curosor总是得到偶数Id行,这里是我的代码
String notificationText = null;
this.openDataBase();
Cursor cursor = this.myDataBase.query("message", new String[]{"id","message"}, "active=?", new String[]{"1"}, null,null, "id ASC", "1");
if (cursor != null)
{
cursor.moveToFirst();
notificationText = cursor.getString(cursor.getColumnIndex("message"));
int notificationId = cursor.getInt(cursor.getColumnIndex("id"));
ContentValues cv = new ContentValues();
cv.put("active", 0);
cursor.close();
this.myDataBase.update("message", cv, "id=" + notificationId, null);
}
return notificationText;
所以,如果有人暗示可能出错的话,我会很感激。