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