March 2013
Beginner to intermediate
580 pages
16h 11m
English
Your next task is to show the user a line that follows his or her run. The Maps API makes this trivial, but you need to fetch the list of locations so you know how to build the line. Add a method to both RunDatabaseHelper and RunManager to provide a LocationCursor with this data.
Listing 36.7 Querying a run’s locations (RunDatabaseHelper.java)
public LocationCursor queryLocationsForRun(long runId) {
Cursor wrapped = getReadableDatabase().query(TABLE_LOCATION,
null,
COLUMN_LOCATION_RUN_ID + " = ?", // Limit to the given run
new String[]{ String.valueOf(runId) },
null, // group by
null, // having
COLUMN_LOCATION_TIMESTAMP + " asc"); // order by timestamp
return new LocationCursor(wrapped);
}
The queryLocationsForRun(long) ...
Read now
Unlock full access