Search code examples
javaandroidandroid-contentproviderandroid-cursorloaderandroid-loadermanager

Using Loader em API version prior to 11


I am using a CursorAdapter and ContentProvider, and I want to use CursorLoader, so I reconfigured my project to target API 11 and set min-sdk-ver to 7. However it crashes when an Activity calls a sub-Activity which uses the CursorLoader. The error is NoClassDefFoundError delivered via IllegalStateException.

My question is can we use Honeycomb APIs in previous Android versions even if we have the same configs a have?


Solution

  • If you wish to use CursorLoader in an Android application supporting pre-API Level 11 devices, you will need to use the Android Compatibility Library (ACL). You can download that via the SDK and AVD Manager and copy the JAR from your SDK installation into your project. Then, you will need to use support.v4 versions of the loader classes, plus inherit from FragmentActivity, so you can call getSupportLoaderManager() to get your ACL edition of the LoaderManager.

    This blog post describes (briefly) the ACL. A sample app using CursorLoader is found packaged with the ACL itself. You can also review a tutorial on using ACL's edition of CursorLoader.