1

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..

jpmd
  • 247
  • 1
  • 7
  • 19
  • 2
    What do you mean, you don't know how to use it? Just as you said, call `notifyDataSetChanged()` on your ListView... – Kevin Coppock Apr 13 '11 at 13:33
  • i dont know how to use it.. how i call the notifyDataSetChanged()?? – jpmd Apr 13 '11 at 13:47
  • There's no way that you know how to query a SQLite Database but don't know how to call a method...I'm not really sure how to simplify it: `listView.notifyDataSetChanged();` – Kevin Coppock Apr 13 '11 at 13:51

1 Answers1

5

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.
Flo
  • 27,355
  • 15
  • 87
  • 125