Курсор всегда -1
Прежде чем у меня есть
db.getWritableDatabase
TABLE_NAME_NOTES
в каждых трех местах отмечает
public String addNote(){
String id = "";
ContentValues values = new ContentValues();
values.put("Date","date");
db.insert(TABLE_NAME_NOTES, null, values);
Cursor cursor = db.rawQuery("select last_insert_rowid() as fullname from " + TABLE_NAME_NOTES, null);
if (cursor.moveToFirst()){
do {
id = cursor.getString(0);
} while(cursor.moveToNext());
}
cursor.close();
cursor = db.rawQuery("SELECT _id FROM " + TABLE_NAME_NOTES, null);
if(cursor.moveToLast()){
long long_id = cursor.getInt(0);/
id = Long.toString(long_id);
}
cursor.close();
return id;
}
Как я могу получить последний идентификатор?