After creating a standard SQLite cursor, I’m iterating thru the entries using:
while (cursor.moveToNext()) {
}
All the rows are being processed correctly.
All the documentation I’ve read states you need to issue a moveToFirst() to ensure
that you’re pointing to the first entry of the cursor set.
Is this working even though it shouldn’t,
and another release may not have the same processing?
No, this is working correctly.
Cursors begin at row index -1 (before the first row). If theCursorreferences multiple rows, looping through them with thewhileloop as you have suggested is the preferred method. It will callmoveToNext(), which moves you to index 0 (the first row), and go from there.If your
Cursoronly references one row, you may callmoveToFirst()on it before reading data to ensure that you are on a valid index. BothmoveToFirst()andmoveToNext()have the same effect when theCursoris first created and is at index -1.