Method deleteContact

Method deleteContact (Fig. 8.57) uses SqLiteDatabase’s delete method (line 98) to delete a contact from the database. In this case, we retrieve all the columns in the database for the contact with the specified ID. The three arguments are the database table from which to delete the record, the WHERE clause (without the keyword WHERE) and, if the WHERE clause has arguments, a String array of values to substitute into the WHERE clause (null in our case).

94   // delete the contact specified by the given String name95   public void deleteContact(long id)96   {97      open(); // open the database98      database.delete("contacts", "_id=" + id, null);99      close(); // close the database100   } ...

Get Android™ How to Program, Second Edition 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.