I'm sorry, I've tried looking at a bunch of other answers, but I can't get my particular implementation to work.
I have a ListView
populated by an extended SimpleCursorAdapter
. In the onCreate()
method I set it up this way:
list = (ListView) findViewById(R.id.duty_history_list);
list.setOnItemClickListener(this);
list.setOnItemLongClickListener(this);
masterCursor = db.rawQuery("SELECT * FROM WorkLog", null);
list.setAdapter(new NotSoSimpleCursorAdapter(this,
R.layout.log_list_item,
masterCursor,
columns,
views,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER));
When an item is long clicked, the corresponding row is deleted from the db. Here is my attempt to update the view. With this code, nothing happens, I'm not sure why. IT is called at the very end of handleItemLongClick()
, after the db is updated.
public void refreshView() {
CursorAdapter cA = (CursorAdapter) list.getAdapter();
masterCursor = db.rawQuery("SELECT * FROM WorkLog", null);
cA.changeCursor(masterCursor);
}