What does LoaderManager do?
I am trying to understand wh开发者_Python百科at 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.
Simply stated, the LoaderManager
is responsible for managing one or more Loader
s 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 Loader
s.
There is a pretty extensive and in-depth blog post on the LoaderManager
... check it out here:
Understanding the LoaderManager (part 2)
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.
精彩评论