vendredi 23 octobre 2015

I need primary key id after storing data instant

I'm working in search functionality here I need key id of currently stored data.. then select required data using of this key. Use this function getting id=0 and the process used to get stuck.

onCreate(){
int id=getHighestID();
fetchData(id);
}
    public int getHighestID() {
        dba.open();
        final String MY_QUERY = "SELECT last_insert_rowid()";
        Cursor cur = dba.rawQuery(MY_QUERY, null);
        cur.moveToFirst();
        int ID = cur.getInt(0);
        cur.close();
        dba.close();
        return ID;

    }

is there any strategy to get data from database after recently inserted.

Aucun commentaire:

Enregistrer un commentaire