Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which permission should be added to add contact?

I am trying to add a new contact in android phone. For that I am using following code.

ContentValues values = new ContentValues();
                values.put(Phone.RAW_CONTACT_ID, "jadeja");
                values.put(Phone.NUMBER, 1234567890);
                values.put(Phone.TYPE, Phone.TYPE_MOBILE);
                Uri uri = getContentResolver().insert(Phone.CONTENT_URI, values);

But it force closes the application and inside "LogCat" it shows that security permission denial. Is there any way to achieve this?

like image 202
Jaydeepsinh Jadeja Avatar asked Mar 06 '12 10:03

Jaydeepsinh Jadeja


2 Answers

Add the following to the AndroidManifest.XML file:

<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
like image 171
ankit0311 Avatar answered Oct 19 '22 08:10

ankit0311


This should be added in manifest WRITE_CONTACTS

like image 23
Rohit Avatar answered Oct 19 '22 08:10

Rohit