March 2013
Beginner to intermediate
580 pages
16h 11m
English
The new SQLiteCursorLoader class is fine for loading data that you want to remain in a cursor (such as a list of things), but in the RunFragment, you are loading two individual objects and the cursor is hidden by the RunManager. To best handle loading arbitrary data, you need a more generic loader.
In this section, you will create a new DataLoader class that is a subclass of AsyncTaskLoader. DataLoader will take care of some simple tasks that any subclass of AsyncTaskLoader should, leaving only the implementation of loadInBackground() to its own subclasses.
Create DataLoader using the code in Listing 35.5.
Listing 35.5 A simple loader for data (DataLoader.java)
public abstract class DataLoader<D> extends AsyncTaskLoader<D> { ...Read now
Unlock full access