Search code examples
androidandroid-contactsandroid-contentprovider

Can not update contact using ContentProvoider


Uri name=null;
           String []whereargs={"Sameer Ahmad"};
    name=Uri.withAppendedPath(People.CONTENT_URI,People.Phones.CONTENT_DIRECTORY);
    cv1.put(People.NAME,"Tofeeq Ahmad");
    int i1=0;
    i1=getContentResolver().update(name,cv1,"name=?",whereargs);
    }
    catch(Exception e){
        e.getMessage();

I am trying to update a phone numder by URi but its showing the Exception:Cannot Update//Contacts/people/phone.Same error in inserting.

  1. I want to create shared data base which will be accessible from every application

Solution

  • have you declared the necessary permission in your manifest?

    <uses-permission android:name="android.permission.WRITE_CONTACTS" />