I need a lot of code to check the results of the database over and over again.
Cursor cursor = db.rawQuery(...);
cursor.moveToFirst();
while (cursor.isAfterLast() == false)
{
...
cursor.moveToNext();
}
Cursor cursor = db.rawQuery(...);
for (boolean hasItem = cursor.moveToFirst();
hasItem;
hasItem = cursor.moveToNext()) {
...
}
Cursor cursor = db.rawQuery(...);
if (cursor.moveToFirst()) {
do {
...
} } while (cursor.moveToNext());
}
All of these codes are too long and call the Cursor method several times, so is there a simpler code?
android cursor
while (cursor.moveToNext()) {
...
}
cursor.close();
You can do it like this. The cursor starts before the first row and moves to the first row when you call moveToNext. Returns false if the first row is empty or the last row is reached.
© 2024 OneMinuteCode. All rights reserved.