Why does a delete rawQuery need a moveToFirst in order to actually delete the rows?

前端 未结 5 1224
难免孤独
难免孤独 2020-12-29 23:40

I have been struggling for hours trying to debug why the following delete query actually didn\'t delete anything even if the exact same query on the exact same database work

5条回答
  •  灰色年华
    2020-12-30 00:25

    A rawQuery returns a Cursor of a result set, which is just a reference to the query results. You should just be using a straight delete() call. Take a look at the documentation:

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

    or an SQLiteStatement:

    http://developer.android.com/reference/android/database/sqlite/SQLiteStatement.html

提交回复
热议问题