There are several guides for implementing custom AsyncTaskLoaders, but not one of them discusses how to handle data caching - in all of them, data is simply loaded and delivered.
Can you give me some tips on how to implement a custom AsyncTaskLoader that will immediately return cached versions of the data, but at the same time, request data updates and deliver updated versions of them as soon as they appear? Is this possible with Loaders or do I need to use a different mechanism and which one?
Background: I have an IntentService that accepts data download requests and transmits the results to the broadcast. I have a user interface (ListView) that needs to display this data from an ArrayAdapter or CrusorAdapter. I need some layer of "caching", which will show the latest versions of the data that will be displayed immediately, but gives them an update and re-displays them as soon as new data appears.
Although this could be done with a dumb SQLite database for immediate versions and a broadcast receiver for a new data update, I would prefer something that would make this backgorund data loading mechanism transparent, like the Loader class obtained by IMHO.
source share