Save User-Entered Data

The intTextChangedEvents method you just created sets the stage for saving the contact’s data. It sets the EditTexts to update the ContactActivity’s contact object with any changes users make as they make them. All that is left is to pass that object to the insert or update method in the ContactDataSource class so that the changes can be stored in the database. This requires the addition of a method that initializes the Save button and executes the code that will do the save operation when the button is pressed.

The initialization of the Save button is similar to the initialization of all the other buttons you have coded so far. The only difference is what happens when the button is pressed. Enter the code in Listing 5.6 ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.