Wednesday, June 03, 2009

SQLite Cursors and Content Values:

ContentValues objects are used to insert new rows into database tables (and Content Providers). Each Content Values object represents a single row, as a map of column names to values. 
Queries in Android are returned as Cursor objects. Rather than extracting and returning a copy of the result values, Cursors act as pointers to a subset of the underlying data. Cursors are a managed way of controlling your position (row) in the result set of a database query. 

The Cursor class includes several functions to navigate query results including, but not limited to, the following:

moveToFirst >> Moves the cursor to the fi rst row in the query result.

moveToNext >> Moves the cursor to the next row.

moveToPrevious >> Moves the cursor to the previous row.

getCount >> Returns the number of rows in the result set.

getColumnIndexOrThrow >> Returns an index for the column with the specifi ed name (throw-
ing an exception if no column exists with that name).

getColumnName >> Returns the name of the specifi ed column index.

getColumnNames >> Returns a String array of all the column names in the current cursor.

No comments: