vendredi 6 mars 2015

Best architectural choices to use ContentProviders, IntentServices and Loaders

I working on an Android project in which I need to fetch JSON data from a remote server, update a SQLite Db with the retrieved data and update a listview.


I am using IntentServices to fetch data (I do not need regular updates) while the DB is wrapped by a ContentProvider and thus accessed by ContentResolvers.


Now I need to update the views. To this end I think I should rely on loaders but I am wondering about what would be the best architectural choice.


I would make the Activity/Fragment hosting the listView a ContentObserver and register it to the ContentProvider AND, when data is changeged (onChange method), start a Loader aimedt a querying the data and updating the view.


This would work for updates to the DB but when the application is started. I therefore need to explicitly start a Loader in the onCreate method of the Activity/Fragment.


Am i Right?


Aucun commentaire:

Enregistrer un commentaire