内置游标功能,不会影响行

时间:2014-01-04 07:26:43

标签: android sqlite cursor

这是我创建的更新功能。它工作正常,但我想知道我们在哪里可以使用任何能让我们知道受影响的行数的函数。例如,在Oracle中,我们有rowcount()函数。

int updatestatus(String email) {
    int up = 0;
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cur = db.rawQuery("update " + logintable + " set " + flag +" = 1  where " + UID + " = " + email ,null);
    cur.moveToFirst();
    up = 1;
    return up;
}

1 个答案:

答案 0 :(得分:0)

试试这个::

ContentValues newValues = new ContentValues();
newValues.put("YOUR_COLUMN", "newValue");

int RowsUpdated = db.update("YOUR_TABLE", newValues, "id=6", null);

此处RowsUpdated将返回受查询影响的行数。

希望它能帮助!!