Android - Loader (Asynchronously load data)


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:

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


Android 2.3 compatibility with the below imports. is used to write apps that run on platforms prior to Android 3.0.


Documentation / Reference

Powered by ComboStrap