I thought it would be another way to control it, but i found my way without doing this SELECT. Here are two solutions:
- With SELECT
With SELECT (proposed by other user on this post - check it for more details)
public int getPrimaryId() {
final String MY_QUERY = "SELECT MAX(_id) FROM " + DATABASE_TABLE0;
Cursor cur = mDb.rawQuery(MY_QUERY, null);
cur.moveToFirst();
int ID = cur.getInt(0);
cur.close();
return ID;
}
Override method
Override .insert() method, inside myObjectDAO.java
@Override public long insert(Stud_Course entity) { long ret = 0; try { ret = super.insert(entity); } catch (Exception e) { ret = 0; Log.e("LOG", "fail to insert!!!"); } return ret; }