Increase the value of a record in android/sqlite database

前端 未结 1 828
谎友^
谎友^ 2020-12-06 00:27

I try to increase the value of an integer key in a row in my table. However, nothing really seems to happen.

db.rawQuery(\"UPDATE table SET key = key + 1 WH         


        
1条回答
  •  春和景丽
    2020-12-06 00:56

    From http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html:

    public Cursor rawQuery (String sql, String[] selectionArgs)

    Runs the provided SQL and returns a Cursor over the result set. Returns a Cursor object, which is positioned before the first entry

    compared to:

    public void execSQL (String sql, Object[] bindArgs)

    Execute a single SQL statement that is not a query. For example, CREATE TABLE, DELETE, INSERT, etc.

    In other words, SQL queries which return a table are to be run with rawQuery, and those that do not return tables are to be run with execSQL.

    0 讨论(0)
提交回复
热议问题