RecyclerViewCursorAdapter Library

Today I released my first library which is for a RecyclerviewCursorAdapter.

Using a ListView to display database data becomes a lot easier when you use a CursorAdapter combined with a CursorLoader to display data from your ContentProvider. The main benefit of CursorLoader is explained in the docs:

This class implements the Loader protocol in a standard way for querying cursors, building on AsyncTaskLoader to perform the cursor query on a background thread so that it does not block the application’s UI.

The CursorAdapter helped by efficiently clearing the reference to the Cursor that it held, so the responsibility didn’t fall on the developer.

When ListView was replaced by RecyclerView, it came with a different type of Adapter with no CursorAdapter implementation. After being inspired by a StackOverflow answer to see how a CursorAdapter could be used as the underlying data source of a RecyclerView.Adapter class, I quickly abstracted the idea into a library. You can find this library with samples on GitHub. The README there will explain how to include this library in your project and get started using the CursorAdapter with your RecyclerView!

Adam McNeilly

Adam McNeilly
Adam is a Google Developer Expert for Android. He's been developing apps since 2015, and travels the world to present and learn from other Android engineers.

Interface Naming Conventions

Many engineers will tell you that one of the most complicated responsibilities of our job is naming things. Variables, classes, functions...… Continue reading