Tutorial by Examples

AsyncTaskLoader is an abstract Loader that provides an AsyncTask to do the work. Here some basic implementation: final class BasicLoader extends AsyncTaskLoader<String> { public BasicLoader(Context context) { super(context); } @Override public String loadInBa...
It's a good practice to cache loaded result to avoid multiple loading of same data. To invalidate cache onContentChanged() should be called. If loader has been already started, forceLoad() will be called, otherwise (if loader in stopped state) loader will be able to understand content change with ta...
To invalidate your old data and restart existing loader you can use restartLoader() method: private void reload() { getLoaderManager().reastartLoader(LOADER_ID, Bundle.EMPTY, this); }
You can pass parameters by Bundle: Bundle myBundle = new Bundle(); myBundle.putString(MY_KEY, myValue); Get the value in onCreateLoader: @Override public Loader<String> onCreateLoader(int id, final Bundle args) { final String myParam = args.getString(MY_KEY); ... }

Page 1 of 1