MoveToNext () - false

//row --> 2
int row = mCursor.getCount();
for (int i = 0; i < row; i++) {
 if (mCursor.moveToPosition(i)){
  int val = mCursor.getInt(mCursor.getColumnIndexOrThrow(UTILI_COLLOC_ID_UTILI))
 }
}

I do not understand, because I have 2 lines in my request. But when I want to read the second line with "mCursor.moveToPosition (i)", then it is wrong ... Why?

+3
source share
2 answers

I think you can just use it safely

while(mCursor.moveToNext()) {
// code
}

instead of a cycle

+1
source

You have 2 lines: 0th and 1st. I think your problem here is that you go to the next record in a loop and the cursor is already moved to the last record. therefore he returns you FALSE.

Solution: put mCursor.moveToPosition (1); towards the for loop.

+1
source

Source: https://habr.com/ru/post/1777589/


All Articles