Updating the Model

Now you will update the trip model to insert, update, and delete trips.

1. Open the Trip model class in com.androiddevcom.onyourbike.chapter7.model. Add insert, update, and delete methods, all returning nothing and taking a single parameter named database of type SQLiteDatabase. The insert method takes an extra parameter of type long named route_id (see Listing 7.37).

Listing 7.37 Creating the Methods to Insert, Update, and Delete Trips

public void insert(SQLiteDatabase database, long route_id) {}public void update(SQLiteDatabase database) {}public void delete(SQLiteDatabase database) {}

2. In the insert method, create a local variable named insertRow, and assign it the SQL to add a trip to the ...

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.