Using cursor loaders

I am writing an Android application and asking myself how to control cursors. I know how to get data using a cursor from a database. I do not want to handle the life cycle of these cursors myself. For Android 2.x and below, I used, according to the Android API, methods such as manageQuery and startManagingCursor. These methods are now outdated. Instead of these methods I should use the Loader class (CursorLoader). As far as I know, CursorLoader should be supported by ContentProvider. The Android SDK recommends ContentProvider only if I want to share my data. But I just want to write a simple application in which data should not be shared. In all my research, I just find tutorials about downloaders combined with ContentProvider. The SDK says that I can write my own bootloader on the AsyncTaskLoader class.Does anyone already have experience with such a bootloader? Are there any best practices? Are there any good futuristics, how to implement such a loader? Or is it better to implement ContentProvider, so I can use CursorLoader (this means that working with a controlled cursor requires a lot of work)?

+3
source share
2 answers

To make ContentProvider private android:exported="false"in your manifest.

0
source

ContentProviders are easier than you think and the proposed method for the Android team. See http://responsiveandroid.com/2012/03/19/using-an-android-cursor-loader-with-a-content-provider.html for a good example of creating a ContentProvider.

0
source

All Articles