How to create Android Contact Book App : Part 6 : Updating Contact Details into Database

In this part you will learn, how to update contact details into database.


Table of Contents

  1. Creating Option Menu
  2. Passing Contact data to Edit Contact Activity
  3. Setting up Edit Contact Activity
  4. Updating Contact Details to Database

Creating Option Menu

Open existing “ContactDetails.java” file from the Part 5 Source files. And add following code to create Option Menu.

device-2013-10-27-172451

Passing Contact data to Edit Contact Activity

After creating Option Menu we have to add Item Select event. And Pass the data to Edit Activity for Editing Data. See code below.

Setting up Edit Contact Activity

Create a new Activity named “EditContact.java”. And add it into AndroidManifest.xml under Appliction Node.

Now setup the Layout to Activity. For Edit Contact we can use same layout as we used previously for NewContact Activity. And load all the passed data come from last activity.

Updating Contact Details to Database

Now get all the data from Input fields and ImageView and set it into new Contact Object.

After setting into object Pass Object to database handler

Function into ContactHandler Class

And load Main Activity once data get updated into database.

snap

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *