Movetofirst and MoveToNext of the cursor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.