Enter your keyword

Android SQLite Database Tutorial II

Android SQLite Database Tutorial II

Android SQLite Database Tutorial II

This is part II of using SQLite in Android tutorials if you haven’t read the first tutorial, please consider doing so. In this part, were going to use the SQLite utility classes Contact and ContactHelper that we create previously to create a phone book application were the user can add contacts to the phone book, view contacts in the phone book, view|edit contact details, as well as delete a contact from the phone book.

0. Project Structure

Project Structure

Add Contact

Android SQLite Add Contact

Android SQLite Add Contact

View Contacts

Now lets view display all the contact in the phone book using a ListView. We need create a custom CursorAdapter to load the Contacts cursor that we will receive from the database.

2. Phonebook

View Contact Details

3. View Contact

Edit Contact


4. Edit Contact

Delete Contact
5. Contact Context Menu 6. Delete Contact

I have used a Context Menu to show the Edit and Delete options when a user long presses on a contact in the phone book.
There’s a separate tutorial demonstrating how to implement a Context Menus for your ListView which you can read here.

Thank you for following through this whole tutorial, I have strived to introduce the basic usage of SQLite in Android and hope this tutorial has gotten you started for that purpose. Please feel free to leave me you feedback regarding this tutorail in the comments section and remember; the complete source code for this application is available on GitHub for those that might need it.

Download Project