Is Android Cursor.moveToNext() Documentation Correct?

后端 未结 5 1919
春和景丽
春和景丽 2021-01-12 03:00

boolean android.database.Cursor.moveToNext() documentation says:

http://developer.android.com/reference/android/database/Cursor.html#moveToNext%28%29

Move th

5条回答
  •  迷失自我
    2021-01-12 03:07

    A simpler idiom is:

    Cursor cursor = db.query(...);
    while (cursor.moveToNext()) {
        // use cursor
    }
    

    This works because the initial cursor position is -1, see the Cursor.getPosition() docs.

    You can also find usages of cursors in the Android source code itself with this Google Code Search query. Cursor semantics are the same in SQLite database and content providers.

    References: this question.

提交回复
热议问题