Method deleteContact and DialogFragment confirmDelete

Method deleteContact (Fig. 8.50, lines 193–197) displays a DialogFragment (lines 200–252) asking the user to confirm that the currently displayed contact should be deleted. If so, the DialogFragment uses an AsyncTask to delete the contact from the database. If the user clicks the Delete Button in the dialog, lines 222–223 create a new DatabaseConnector. Lines 226–241 create an AsyncTask that, when executed (line 244), passes a Long value representing the contact’s row ID to the doInBackground, which then deletes the contact. Line 232 calls the DatabaseConnector’s deleteContact method to perform the actual deletion. When the doInBackground completes execution, line 239 calls the listener’s ...

Get Android™ How to Program, Second Edition now with O’Reilly online learning.

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