I am trying to update my listfragment when a button is pressed. the button puts a name into a database but how do I update the list so that name appears? the listfragment uses a cursorLoader to load from the database. I even tried using a content observer on the database and calling getLoaderManager().restartLoader() but that didnt work either.
So what can I do to update the list when I click a button in an activity? I have found very little information on this please help
I can’t be sure, but I assume there is something weird going on with the interaction between your
Fragmentand yourActivity, which you are apparently displaying simultaneously somehow. Is there any reason why you are listening for the Button in the Activity? Are you dealing with a multi-pane screen or something? It seems like it’d be a lot simpler to just have the Fragment deal with this itself (since it is the one implementing theLoaderCallbacks, I assume).Also, be sure that you are implementing your
Fragmentlifecycle correctly… i.e. you callinitLoader()and set the list’s adapter inonActivityCreated()as opposed toonCreate().Hope that helps!