O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Add Delete Functionality

The final job associated with making the list work properly is to code the capability to delete a contact from the list (and the database). This functionality is primarily implemented in the custom adapter. However, because you don’t want the user to accidently delete a contact, the app provides a button to turn the delete functionality on and off. Four tasks need to be completed to implement the delete function:

1. Add a button to the activity contact_list layout.

2. Code a method to delete a contact from the database in ContactDataSource.

3. Code the custom adapter to delete a contact from the list and database.

4. Code the ContactListActivity to use the delete function of the adapter.

First, add the button to the layout ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required