android - 1st Activity's listview not updated after 2nd activity inserts into database via ContentProvider; onLoadFinished not called -


problem: upon returning 2nd activity first activity's listview not reflect database changes made 2nd activity. if make trivial change code (to make emulator happy) , refire app listview accurately shows database changes 2nd activity made during last session.

the guts of app:

mainactivity: extends activity implements loadermanager.loadercallbacks<cursor> =>oncreate: simplecursoradapter set; getloadermanager().initloader(loader_id, null, this) =>onresume: super.onresume(); getloadermanager().restartloader(0, null, this) 

...oh gawd! there's problem: initloader , restartloader using different loader id's.

this stumped me last 5 hours. why leaving question: in trying solve problem didn't run answer (maybe it's bone-headed of thing suggest for) next person stumbles in unique way, here's potential answer.

make sure loadermanager id's same in initloader , restartloader.

in addition other posts alex , commonsware , rest of them run while searching solution failing-to-update listview, else might have happened you.

during searching wrong noted had not implemented: cursor.setnotificationuri(getcontext().getcontentresolver(), uri);

(how cursorloader automatically updates view if app inactive?)

...two different tutorials following how implement content providers did not have setcontentnotificationuri in providers' query methods; though used querybuilder , did not (maybe setcontentnotificationuri included in querybuilder? quick research didn't suggest case).


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -