I have created a database that holds names, info and also gives an "_id" for each object that gets save to the database.
now i want with the next function to get at the end the id that the new added object is getting - i have tried the next code - but im sure it's not the right way
public long insertAuto(Student student){
SQLiteDatabase db = dbOpen.getWritableDatabase();
ContentValues vals = new ContentValues();
vals.put(Constants.STUDENT_NAME, student.getName());
vals.put(Constants.STUDENT_INFO, movie.getInfo());
db.insert(Constants.TABLE_NAME_STUDENTS, null, vals);
//this is where i thinks is my mistake!
long id = student.getId();
db.close();
return id;
}
so thank you for any kind of help