Thursday, May 2, 2013

[android help] android - delete a row in sql and item in listview


i try to delete a row from my db. I'm using this method:


public void deletePlayerbyID(int id){mDb.delete(SQLITE_TABLE, KEY_ROWID +"="+id, null); }


called in activity :



listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView av, View v, int pos, long id) {
return onLongListItemClick(v,pos,id);
}
protected boolean onLongListItemClick(View v, final int pos, long id) {

AlertDialog.Builder builder = new AlertDialog.Builder(AndroidListViewCursorAdaptorActivity.this);
builder.setMessage("Are you sure to delete?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {bdHelper.open();
dbHelper.deletePlayerbyID(pos);
Log.i("ListView", "onLongListItemClick id=" + pos);
displayListView();
}
})


...........


why i can't delete the selected row from listView? i have a method that delete all db and it work.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...