Question

I am trying to understand what does LoaderManager do. Can anyone share an example with it? Must I use them when I create a cursor? If not how should I use? A simple example is very appreciated.

Was it helpful?

Solution

Simply stated, the LoaderManager is responsible for managing one or more Loaders associated with an Activity or Fragment. Each Activity and each Fragment has exactly one LoaderManager instance that is in charge of starting, stopping, retaining, restarting, and destroying its Loaders.

There is a pretty extensive and in-depth blog post on the LoaderManager... check it out here:

Understanding the LoaderManager (part 2)

OTHER TIPS

In simple words:

LoaderManager load the data in background and also look for the changes in it. It provides a simple Api like structure that we don't need to look and observer the data manually.

Examples:

In <android-sdk>\samples folder search for LoaderCursor.java and LoaderThrottle.java this are the to example using CursorLoader class

Just in case if some one is looking for an example of LoaderManager with the custom AsyncTaskLoader look here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top