Fetching last row from sqlite database
android, sqlite
Solution
If you have already got the `cursor`, then this is how you may get the last record from `cursor`:
cursor.moveToPosition(cursor.getCount() - 1);
then use `cursor` to read values
or
do it like this
Cursor cursor = db.rawQuery(selectQuery, null);
cursor.moveToLast();
or
SELECT * FROM TABLE WHERE ID = (SELECT MAX(ID) FROM TABLE);
Problem
I am trying to fetch the last row from my SQLite database. Until now i have tried max,sql_sequence but nothing seems to work. I have to fetch the row values and assign it to a class variable. Any help is appreciated as I am new to SQLite and Android. Thanks..