3

using the cursor in Android

 3 years ago
source link: https://www.codesd.com/item/using-the-cursor-in-android.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

using the cursor in Android

advertisements

I was going through some of the codes in the internet regarding the database connection, retrieval. I saw Cursor cur1= moveToFirst() in many codes,i wanted to know what is the use of cursor and why we use moveToFirst() as i am new to android.


Cursor is the Interface which represents a 2 dimensional table of any database. When you try to retrieve some data using SELECT statement, then the database will first create a CURSOR object and return its reference to you.

The pointer of this returned reference is pointing to the 0th location which is otherwise called as before first location of the Cursor, so when you want to retrive data from the cursor, you have to first move to the first record so we have to use moveToFirst

When you invokes moveToFirst() method on the Cursor, it takes the cursor pointer to the first location. Now you can access the data present in the first record


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK