I wanted to iterate over a cursor over a table with 2 rows of data. My first try was:
c.moveToFirst();
while(!c.isAfterLast()){
//this code runs once
c.moveToNext();
}
However after debugging I noticed that I am missing the last row of my data. And that was because the while loop ends when the mPos variable becomes equal to mCount in the counter. After replacing the above code with the one below the problem was solved:
c.moveToFirst();
do{
//this code runs twice
}while(c.moveToNext())
Essentially in the first method, the while loop runs 1 time less than the second one. Isn't isAfterLast supposed to return true only after the cursor passes the last row?