About
Loaders provide a framework for the asynchronous loading of data.
They are registered by id in the loaderManager. The loader Id has to be unique for all loader used in the activity.
Loader asynchronously load data, see the Loaders guide.
AsyncTaskLoader is a Loader that uses an AsyncTask behind the scenes to do its work.
You can use:
- or define your loader by implementing AsyncTask
Articles Related
Disadvantage of querying the database from the UI
From the UI = From the activity
- The query could take a long time
- The activity could stop before it completes
- The cursor is tied to the activity, so if the activity restarts, the data must be re-queried
Import
Android 2.3 compatibility with the below imports. android.support.v4. is used to write apps that run on platforms prior to Android 3.0.
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.support.v4.content.CursorLoader;
Documentation / Reference
- Documentation on CursorLoader (ie a loader for a cursor)