Use
cursor.moveToFirst();
do{
}
while (cursor.moveToNext());
--
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-
my bad. I was confusing itn with ADODB. Too many damn programming
languages! :-)
--
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
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 d
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
c
Thanks both of you. It worked!
On Oct 28, 5:35 pm, Kostya Vasilyev wrote:
> 28.10.2011 19:12, André пишет:
>
> > cursor.moveToFirst();
> > while (cursor.moveToNext()) {
> > ...}
>
> > When I use this code the first row in my cursor seems to be skipped.
>
> Of course - the code moves to first row,
Remove the cursor.moveToFirst().
The moveToNext() will move the pointer to the first row the first time
through the while statement.
If you need to reset the cursor before the while loop, try using
cursor.moveToPosition( -1 ).
Steven
Studio LFP
http://www.studio-lfp.com
On Friday, October 28
6 matches
Mail list logo