Trying to get the maximum id in my TABLE_GOALS
public String getLatestGoal(){
SQLiteDatabase db=dbhandler.getWritableDatabase();
//columns
Cursor cursor=db.query(MyDBHandler.TABLE_GOALS, null, "SELECT MAX("+MyDBHandler.COLUMN_ID+"))", null, null, null, null);
StringBuffer buffer = new StringBuffer();
while(cursor.moveToNext()){
int index1=cursor.getColumnIndex(MyDBHandler.COLUMN_ID);
String max_id=cursor.getString(index1);
buffer.append(max_id);
}
return buffer.toString();
}
I can't get the maximum value and i don't know why. Sorry, newbie here in Android.
Aucun commentaire:
Enregistrer un commentaire