Using the Database

The three classes, Contact, ContactDBHelper, and ContactDataSource, are used in the ContactActivity class to implement the saving of contact data to the database. This will require implementing several new methods and modifying some existing methods. Because the methods to retrieve contacts have not been implemented yet, the update functionality will be only partially implemented at this time.

The first step is to provide an association between the ContactActivity class and a Contact object. This is implemented by declaring a private variable in the ContactActivity class. Enter the following code after the class declaration and before the onCreate method:

private Contact currentContact;

Next associate ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android 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.