I need to know how to retrieve data from cursor. I need this because the ringtonemanager returns all the audio files in form of cursor object, I need to know how to retrieve the values.
Anbudan.
A Cursor implementation that exposes results from a query on a SQLiteDatabase . This interface provides random read-write access to the result set returned by a database query.
Calling moveToFirst() does two things: it allows you to test whether the query returned an empty set (by testing the return value) and it moves the cursor to the first result (when the set is not empty).
A Cursor implementation that exposes results from a query on a SQLiteDatabase . SQLiteCursor is not internally synchronized so code using a SQLiteCursor from multiple threads should perform its own synchronization when using the SQLiteCursor.
Once you have the Cursor object, you can do something like this:
if (cursor.moveToFirst()){ do{ String data = cursor.getString(cursor.getColumnIndex("data")); // do what ever you want here }while(cursor.moveToNext()); } cursor.close();
This looks a bit better:
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With