Displaying a Run’s Path

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) ...

Get Android Programming: The Big Nerd Ranch Guide 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.