tags:

views:

22

answers:

0

Hi Friends.....

I have to add organization details in contacts.Here is my code:

Uri newPersonUri = null;
ContentValues personValues = new ContentValues();
// Add name and get its Uri
personValues.put(People.NAME, arrValues[0] + " " + arrValues[1]);
personValues.put(People.STARRED, 0);    // STARRED 0 = Contacts, 1 = Favorites 
personValues.put(People.NOTES, arrValues[9]);   //add notes
newPersonUri = context.getContentResolver().insert(
    android.provider.Contacts.People.CONTENT_URI, personValues);

ContentValues organisationValues = new ContentValues();
Uri orgUri = Uri.withAppendedPath(
    newPersonUri, 
    android.provider.Contacts.Organizations.CONTENT_DIRECTORY);

//Uri orgUri =Uri.withAppendedPath(newPersonUri, "organizations"); 
organisationValues.clear();
organisationValues.put(Organizations.COMPANY, arrValues[10]);
organisationValues.put(Organizations.TITLE, arrValues[11]);
organisationValues.put(Organizations.TYPE, Organizations.TYPE_WORK);
objContext.getContentResolver().insert(orgUri, organisationValues);

It works fine in some phones but in some phones it gives "java.lang.UnsupportedOperationException: Unknown uri: content://contacts/people/201/organizations"

What can be the reason.....

Any help will be appreciated!!!!

Thanks in Advance Nemat