Only 5 items.

Here is the code

sqLiteDatabase.delete("data", "name='" + cursor.getString(2)+"'",null); Log.e("asd", String.valueOf(cursor.getCount())); 

Why cursor.getCount() returns the number 5, when it must return the number 4. Although in the database if you look there are 4 elements.

  • four
    the cursor is not updated after deleting data from the database. This is not a bug, but a feature. It should not be updated - Vladyslav Matviienko
  • @metalurgus, thanks, because of this feature, all the logic of my code is now lost - Andro

1 answer 1

As @metalurgus was noted, the cursor should not be updated, because the cursor is the same object as everyone else, and once writing something to it, you need to rewrite ( query ) to get the changes. Learn more about working with SQLite in Android and the cursors themselves. Try playing with the rawQuery (...) and query (...) methods and always pass values ​​to the function using arguments, not hardcodes, as this affects the security of your database and the application as a whole.