Ok i have built an app like a remainder, every thing works fine but when click to delete, first deleted wrong row, then now not even work.
i now there are lot of same answer to the question, i swear i try every one i found!
there is some thing i do not know!
this code in the MainActivitey:
lvEvent.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
db.deleteEvent(id);
return true;
}
});
here is the deleting part in DataBase:
public boolean deleteEvent(long id){
return ((
db.delete(TB_EVENT, COLUMN.Id + "=" + id, null )
//db.delete(TB_EVENT, COLUMN.id + "=?", new String[] { String.valueOf(id)});
) == 1 ) ? true : false;
}
also there is an adapter to populate the List View.
Aucun commentaire:
Enregistrer un commentaire