Search code examples
javaandroidlistviewadapter

Updating ListView after change to database


I've been creating a simple list app with a TabLayout to store and view several types of things. I've drawn up the structure of my app below.

From the ListView I can click on an item, this launches a DialogFragment that retrieves the item from the database and allows me to edit and save the entry.

Overlaying the ListView, from the MainActivity, I have a FloatingActionButton. This launches the same DialogFragment, this time without content.

This all works just as expected.

What I cannot figure out, however, is how to refresh the ListView after dismissing the DialogFragment (be it after an edit or new entry).

Any pointers to how I can make this happen would be greatly appreciated!

My app structure


Solution

  • when you perform data modification ,when its done you call

    adapter.notifyDataSetChanged(); 
    

    if you are using asynctask then you call this lin in

    onPostExecte(){ // here }