Hello,
I have a ListActivity with a custom CursorAdapter. Using a ContextMenu
I delete a row from the database. My problem is, that after deleting
the row, the ListView is not updated. IIRC the ListView should refresh
automatically. But I also tried to trigger this with a requery() on
the cursor.
Maybe you can give me a hint where I have to look or what I am doing
wrong.
Here is the relevant part from onContextItemSelected(...):
[...]
switch(item.getItemId()) {
case R.id.beeyards_context_delete:
mDatenbank.deleteBeeyard(info.id);
Toast toast = Toast.makeText(this,
R.string.toast_entry_deleted, Toast.LENGTH_SHORT);
toast.show();
//BeeyardsCursorAdapter adapter = (BeeyardsCursorAdapter)
getListAdapter();
//adapter.getCursor().requery(); // Doesn't work
return true;
}
And mDatabase.deleteBeeyard(info.id) deletes the entry:
public boolean deleteBeeyard(long id) {
final SQLiteDatabase dbCon = getWritableDatabase();
int rowsDeleted = 0;
try {
rowsDeleted = dbCon.delete(BeeyardTable.TABLE_NAME,
BeeyardTable.WHERE_ID_EQUALS, new String[]
{ String.valueOf(id) });
} finally {
dbCon.close();
}
return rowsDeleted == 1;
}
Thanks a lot!
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en