下面code被用来更新图像,但它抛出非法或不良值exception.any身体能解决这个问题。
位图位=((BitmapDrawable)image.getDrawable())getBitmap()。
文件F =新的文件(picturePath);
乌里photoUri = Uri.fromFile(F);
添加到数组列表编码的
ops.add(ContentProviderOperation
.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.CONTACT_ID +=?和+ ContactsContract.Data.MIMETYPE +=?,
新的String [] {
的ContactID,
ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE})
.withValue(Photo.Photo_Uri,photoUri).build());
解决方案
请尝试以下
位图位=((BitmapDrawable)image.getDrawable())getBitmap()。
文件F =新的文件(picturePath);
乌里photoUri = Uri.fromFile(F);
这个
insted的替换下面。
位图位=((BitmapDrawable)image.getDrawable())
.getBitmap();
ByteArrayOutputStream BAOS =新ByteArrayOutputStream();
bitmap.com preSS(Bitmap.Com pressFormat.JPEG,80,BAOS);
byte []的B = baos.toByteArray();
和你的数组列表中添加code应该的。
ops.add(ContentProviderOperation
.newUpdate(
ContactsContract.Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.CONTACT_ID
+=?与
+ ContactsContract.Data.MIMETYPE
+=?,
新的String [] {
的ContactID,
ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE})
.withValue(Photo.DATA15,二).build());
The following code is used to update the image but it 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 to array list coding
ops.add(ContentProviderOperation
.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?",
new String[] {
contactid,
ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE })
.withValue(Photo.Photo_Uri,photoUri ).build());
解决方案
Try the following
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
File f = new File(picturePath);
Uri photoUri = Uri.fromFile(f);
insted of this replace the following.
Bitmap bitmap = ((BitmapDrawable) image.getDrawable())
.getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, baos);
byte[] b = baos.toByteArray();
and your array list adding code should be.
ops.add(ContentProviderOperation
.newUpdate(
ContactsContract.Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.CONTACT_ID
+ " = ? AND "
+ ContactsContract.Data.MIMETYPE
+ " = ?",
new String[] {
contactid,
ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE })
.withValue(Photo.DATA15, b).build());