I'm developing an Android application that is targeting API level 8 (2.2, Froyo). I'm using a ContentProvider
and that's simple enough, and I'm using SimpleCursorAdapter
to fill out my list view, but I noticed in the documentation for SimpleCursorAdapter that the flagless constructor is deprecated with the following note:
This constructor is deprecated. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use LoaderManager with a CursorLoader.
Since I'm targeting API level 8, a LoaderManager
isn't tied to an Activity
. The FragmentActivity
class in the compatibility package does this, but I'm not using Fragments.
My question is: how exactly should I be using LoaderManager/CursorLoader
in an app targeting a pre-11 API level? Am I forced to transition to Fragments or should I just revert back to the deprecated SimpleCursorAdapter
constructor (but make use of an AsyncTask
to keep it UI thread friendly, which is what the CursorLoader
is supposed to do)?
Interface associated with an Activity or Fragment for managing one or more Loader instances associated with it. This helps an application manage longer-running operations in conjunction with the Activity or Fragment lifecycle
...and the only types ofActivity
s that are associated for older platforms areFragmentActivity
s. – VeinletFragment
s, but you do at least have to transition to anActivity
that supportsFragment
s (which is trivial). Not disagreeing, just making it more clear in case anybody is still supporting GB or earlier. – Veinlet