开发者

Deleting a row from database and getting the id value of each row in another class

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.setFocusableInTouchM开发者_开发问答ode(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.


results.remove(position); is deleting the item from your list only...

you need to get the id on click over list item and call db's delete method with that id ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜