Edit:
I wrote quite a LoaderManager about LoaderManager in this blog post . Check it out and let me know if this is helpful! :)
Original post:
Definitely, definitely, with the idea of LoaderManager . The CursorLoader class offloads the work of loading data in a stream and keeps the data constant for short activity refresh events, such as orientation changes. Besides executing the initial request, CursorLoader registers a ContentObserver with the ContentObserver you requested and calls forceLoad() on its own when the dataset is changed and thus automatically updated. This is very convenient, since you do not need to worry about executing queries yourself. Of course, you can use AsyncTask to support the user-friendly interface of the application, but it will include much more code ... and implementing your class, for example, to keep the loaded Cursor Activity , for example, will not be simple. The bottom line is that LoaderManager/Loader will do this automatically for you, and also takes care of creating and closing Cursor correctly based on the Activity life cycle.
To use the LoaderManager/CursorLoader in an API level 11 application, simply use the FragmentActivity class in the compatibility pack. A FragmentActivity is just an Activity and was created to support Android compatibility and does not require the use of Fragment in your application. Just use getSupportLoaderManager() instead of getLoaderManager() and you have to be configured. Of course, you could implement the parent FragmentActivity for each screen and display its layout in Fragment (using FragmentActivity.getSupportFragmentManager() in the Activity onCreate() method). This design can facilitate the transition to layered layouts if you ever decide to optimize your tablet app. This is a good learning experience :).
This is a pretty nice tutorial . Try and work your way through it and feel free to leave a comment if you have other questions.
Alex Lockwood Jan 17 '12 at 19:13 2012-01-17 19:13
source share