Reputation: 8071
How to update List Fragment Periodically? I need to query data from SQLite Database and Update ListFragment. For this,can i use Loader Manager?
Am i correct,If i use Loader Manager in my List Fragment,whenever new data availale in sqlite database,it will load that data to my List Fragment Asynchronously?
Upvotes: 0
Views: 587
Reputation: 6447
Make your ListFragment implement Loader.Callbacks.
On the onLoadFinished callback, do something like this;
onLoadFinished (Loader<List<D>> loader, List<D> result){
setListAdapter(new YourListAdapter(esult));
}
Obviously this would depend on what adapter you use and so on.
Call it trough getLoaderManagger.initLoader(int id, Bundle params, , LoaderCallbacks<D> callback);
, passing a unique id everytime you call it (with a value based on current time, for example).
Besides that, you would need a Timer, which TimerTask run() method would simply init the loader.
Upvotes: 1