Refreshing a ListView following a confirm delete dialog

I have started building a database viewer Activity. This will hopefully become something useful for developing and debugging on devices as well as maybe a way to quickly throw CRUD screens together in the future.
One of the features I have added is that tapping on an item brings up a confirm delete dialog. If the user clicks Yes a row from the db is deleted and the underlying activity comes to the front again. The problem I had was that I could not get the list data to refresh.
I tried using SimpleCursorAdapter.notifyDataSetChanged() which did not seem to do anything. Same result for ListActivity.onContentChanged().
I decided to pull the cursor and adapter code out of the onResume() (which does not get called when the 'Activity' in front was only a Dialog) and put it in a private method. I then called this from onResume and after I had done my delete - once the user had clicked the Yes button to confirm. This works fine.
I think these problems came down to me using a dialog instead of a full fledged Activity. When I get the time I will write some test code to see if I can get this mechanism working using notifyDataSetChanged() along with a delete Activity.

Comments

Popular posts from this blog

Building a choropleth map for Irish agricultural data

Early Stopping with Keras

AutoCompleteTextView backed with data from SQLite in Android