Building responsive apps with CursorLoader

CursorLoader is a specialized subclass of AsyncTaskLoader that uses its lifecycle methods to correctly manage the resources associated with a database Cursor.

A database Cursor is a little like an Iterator, in that it allows you to scroll through a dataset without having to worry where exactly the dataset is coming from or what data structure it is a part of.

We're going to use CursorLoader to query the MediaStore for a list of all images on the device. Because CursorLoader is already implemented to correctly handle all of the details of working with a Cursor, we don't need to subclass it. We can simply instantiate it, passing in the information it needs in order to open the Cursor it should manage for ...

Get Asynchronous Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.