Most recent projects use a lot of query data place, all use the cursor, but the cursor of the Movetofirst and MoveToNext usage is somewhat puzzled, the total feeling can first use MOVETOFIRSRT to determine whether the query results are empty, And then use the movetonext while loop to read the data one by one, I do not know where the original idea from where I came from, it seems like this, when the ContentProvider query to get a cursor, the cursor should be in point to the first record position, So the tune does not call Movetofirst are the same. But later wrote wrote it felt contradictory, if really is to get the cursor point to the first, then do not call Movetofirst, direct use while (MoveToNext ()) loop is not the first to jump over it?
The more confused, or directly look at the code, and wrote an example of debug, the original query to get the cursor is pointing to the first record, Therefore, the first call to Movetofirst or MoveToNext after the cursor has been queried can move the cursor to the first record.
The source code of these movexxx is actually through movetoposition to achieve, and record position is an integer variable MPOs. When Movexxxx returns FALSE, MPOs is set to 1, which is the return to the initial state, before the first record.
Here's a record of the mistake you made.
Movetofirst and MoveToNext of the cursor