Get updated rows count from SQLite in Android using a raw query?

前端 未结 4 799
不思量自难忘°
不思量自难忘° 2020-12-07 01:14

How can I get the number of rows updated using an update statement in SQLite in Android?

Note that I need to use some type of raw execute of a SQL state

4条回答
  •  离开以前
    2020-12-07 02:11

    Expanding on Mat and Pang's answers...

    Could we skip the Cursor and use simpleQueryForLong()?

    e.g.

    public long getChangesCount() {
        SQLiteDatabase db = getReadableDatabase();
        SQLiteStatement statement = db.compileStatement("SELECT changes()");
        return statement.simpleQueryForLong();
    }
    

提交回复
热议问题