I want to delete a row from the database. I added the row to the listview and when I press the delete button, only the row gets deleted from the listview but not from database. I have my database in another class. I want to access the id value of the database in my another class in which I have the listview and delete button so as to fire the delete query. So how can I pass the id value of each row to another class? Here is my code I am using to delete a row from listview:
Button btnRemove = (Button) convertView.findViewById(R.id.button1);
btnRemove.setFocusableInTouchMode(false);
btnRemove.setFocusable(false);
btnRemove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
results.remove(position);
notifyDataSetChanged();
}
});
I have this code in myadapter class. My database is in another class, so to delete a row from db I need the id value. So how can I get the id value from that class to this class? This class extends Arrayadapter. Please help me.
you need to get the id on click over list item and call
db's deletemethod with that id …