Use Contacts.People.setPhotoData to insert a photo.

On Jul 23, 9:21 pm, Serkan Ozel <[email protected]> wrote:
> Hello Friends,
>
> I was wondering if anyone has been able to accomplish this.
>
> I'm able to insert entries into contacts (from my app) with name,
> phone and email however I can't seem to add a photo to these
> entries.
>
> This works:
> ContentValues values = new ContentValues();
> values.put(People.NAME, "Serkan Ozel");
> Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
>
> continuing this fails:
> photoUri = Uri.withAppendedPath(uri,
> Contacts.Photos.CONTENT_DIRECTORY);
> values.clear();
> values.put(Contacts.Photos.DATA, image.getByteArray());
> getContentResolver().insert(photoUri, values);
>
> This is the stack trace:
> java.lang.UnsupportedOperationException: Cannot insert into URL:
> content://contacts/people/36/photo
> at android.database.DatabaseUtils.readExceptionFromParcel
> (DatabaseUtils.java:131)
> at android.database.DatabaseUtils.readExceptionFromParcel
> (DatabaseUtils.java:111)
> at android.content.ContentProviderProxy.insert
> (ContentProviderNative.java:340)
> at android.content.ContentResolver.insert(ContentResolver.java:476)
>
> Any help would be appreciated.
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to