Refresh an listView after insert on database

2019-06-05 15:50发布

问题:

I want to refresh the listView after an insert or delete in the database.. I search and i found notifyDataSetChanged () but i don't know how to use it..

Someone can explain how to do this? Even by a different way..

回答1:

When the delete button is clicked do the following:

  1. Delete the corresponding list item from the database.
  2. Get an new cursor for your list by executing the query which fills the list again.
  3. Bind the new cursor to the list using changeCurosr().
  4. Call notifyDataSetChanged() on the adapter.