I have two table "TABLE_EXAM" and "TABLE_QUESTION". I need to store the question in table with exam id. My question is that how to gel last id of exam table?
Thanks in advance.. Edited Question
Here is my sample code.
public int getLastExamId() { int id2=0; try { SQLiteDatabase db=this.getWritableDatabase(); Cursor cursor=db.rawQuery("SELECT * from SQLITE_SEQUENCE", null); if(cursor.moveToLast()) { id2=cursor.getInt(0); } } catch(Exception e) { e.printStackTrace(); } return id2; }
SELECT MAX(_ID) from TABLE_EXAM.