android - How to Update contact image using contact provider operation. -
the following code used update image throws illegal or bad value exception.any body can solve this.
bitmap bitmap = ((bitmapdrawable)image.getdrawable()).getbitmap(); file f = new file(picturepath); uri photouri = uri.fromfile(f);
add array list coding
ops.add(contentprovideroperation .newupdate(contactscontract.data.content_uri) .withselection( contactscontract.data.contact_id + " = ? , " + contactscontract.data.mimetype + " = ?", new string[] { contactid, contactscontract.commondatakinds.photo.content_item_type }) .withvalue(photo.photo_uri,photouri ).build());
try following
bitmap bitmap = ((bitmapdrawable)image.getdrawable()).getbitmap(); file f = new file(picturepath); uri photouri = uri.fromfile(f);
insted of replace following.
bitmap bitmap = ((bitmapdrawable) image.getdrawable()) .getbitmap(); bytearrayoutputstream baos = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 80, baos); byte[] b = baos.tobytearray();
and array list adding code should be.
ops.add(contentprovideroperation .newupdate( contactscontract.data.content_uri) .withselection( contactscontract.data.contact_id + " = ? , " + contactscontract.data.mimetype + " = ?", new string[] { contactid, contactscontract.commondatakinds.photo.content_item_type }) .withvalue(photo.data15, b).build());
Comments
Post a Comment