Nope, the initial position is *before* the first row.

... which is why a loop like this loops over all rows, first included:

cursor = db.query(...)
while (cursor.moveToNext()) {
cursor.getString(...)
}

... and: Android cursors aren't kept open (as far as the database goes) - query() preloads data from the database into memory before returning.

Many ListView's keep an Android cursor open for a long time, with no ill effects. Managed cursors are kept open and repeatedly iterated and requeried, as well. ( these two cases are often combined )

-- Kostya

29.10.2011 0:24, lbendlin пишет:
there is no need to use cursor.moveToFirst() when you open the cursor the first time. It already is at the first row. You only need moveToFirst() when you want to iterate through a recordset again. Although I think if you need to do that then something's not right in your app design. keeping cursors open asks for trouble.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to