tags:

views:

57

answers:

2

How do I get the row ID from a Cursor?

+1  A: 
id = cursor.getColumnIndex(NAME);
Aleksander O
+1  A: 

I don't think the Cursor exposes this directly. SQLiteDatabase.insert() returns the row id of the newly inserted row. Or in Android the convention is that there is a column named _id that contains the primary autoincrement key of the table. So cursor.getLong(cursor.getColumnIndex("_id")) would retreive this.

Nic Strong