Android: CursorLoader, LoaderManager, SQLite Android: CursorLoader, LoaderManager, SQLite android android

Android: CursorLoader, LoaderManager, SQLite


I've written a blog post on this subject. You can also check out this answer for more information. Hopefully it will clear things up for you.

As Barak mentioned, one can implement a CursorLoader without content providers by extending AsyncTaskLoader<Cursor> class. That said, most of the tutorials and sample code use ContentProviders, and it seems like the Android team encourages its use as well. It's also a lot less complicated than implementing your own class.

That said, if you really don't want to use content providers, Dianne Hackborn (one of the Android framework developers, and also known as "hackbod" here on SO) suggests writing your own loader that uses your database class instead of a content provider. The easiest way is just to take the source of the CursorLoader class from the compatibility library, and replace provider queries with queries to your own db helper class.


Yes you can, You can have Custom data loaders which can load objects that you define or any object type or list in that matter.

Just look into the samples from the android sdk for the LoaderCustomSupport.java in the compatibility library samples and demos.