2

I am trying to save the contact details to the android contacts through my application. I do not want to have the default contact application to do this job, instead I need to do this from my code directly. Here is the code which I use. After the button onclick, I would require to have the contact detail stored to the cntact in android, which, unfortunately is not happening.

Can someone please guide me where I am going wrong in this code and what need to be done in order to resolve the issue.

Any help in this regard is well appreciated.

Regards, Rony

            ContentValues values = new ContentValues();
            values.put(Phone.NUMBER, "456456");
            values.put(Phone.TYPE, Phone.TYPE_WORK);
            Uri uri = getContentResolver().insert(Phone.CONTENT_URI, values); 
user264953
  • 1,837
  • 8
  • 37
  • 63
  • What affect are you seeing? An exception, or nothing happens? What uri is returned? How are you testing that it is not being saved? – Cheryl Simon Dec 16 '10 at 20:01
  • The details of the exception I have posted here http://pastebin.com/L5AvbLRK – user264953 Dec 16 '10 at 20:08
  • please do not leave this unresolved..experts please guide – user264953 Dec 16 '10 at 20:20
  • You only asked this 2 hours (before you posted your last message). No one wants to follow a pastebin link. Post what your error is, what you're seeing, what you're expecting and maybe we can help. – Falmarri Dec 16 '10 at 23:04

1 Answers1

1

I look for a solution for this problem and I found this. http://developer.android.com/reference/android/provider/ContactsContract.Data.html

There are examples there for any kind of operations. This is the insert example.

 ContentValues values = new ContentValues();
 values.put(Data.RAW_CONTACT_ID, rawContactId);
 values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
 values.put(Phone.NUMBER, "1-800-GOOG-411");
 values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
 values.put(Phone.LABEL, "free directory assistance");
 Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);

I hope it helps you.

rogcg
  • 10,451
  • 20
  • 91
  • 133