开发者

Issue in saving contacts to android - code attached

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 some开发者_Go百科one 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); 


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜