35Loading Asynchronous Data With Loaders
In Chapter 34 you implemented data storage in RunTracker using SQLite and used Cursors on the main thread of the application. This was a cop-out, however: it’s a best practice to keep database work off of the main thread as much as possible.
In this chapter, you will use Loaders to pull data for runs and locations from the database on a background thread. The loader API was introduced in Android 3.0 (Honeycomb) and is also available in the support library, so there is no reason not to use them in a modern application.
Loaders and the LoaderManager
A loader is designed to load some kind of data (an object) from some source. The source could be disk, a database, a ContentProvider, the network, or another process. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access