ContentResolver resolver =xxxxActivity.this.getContentResolver();
String where = "mimetype ='vnd.android.cursor.item/photo'";
//查询
while (cursor.moveToNext()) {
int contractID = cursor.getInt(0);
StringBuilder sb = new StringBuilder("contractID=");
sb.append(contractID);
uri = Uri.parse("content://com.android.contacts/contacts/" + contractID + "/data");
Cursor cursortx = resolver.query(uri, null, where, null, null);
while (cursortx.moveToNext()) {
photobyte= cursortx.getBlob(cursortx.getColumnIndex("data15"));
}
}
//插入
values.clear();
values.put("raw_contact_id", id);
values.put("mimetype", "vnd.android.cursor.item/photo");
values.put("data15", photobyte);
resolver.insert(uri, values);
Bitmap bm = BitmapFactory.decodeFile(filepath);
bm.compress(Bitmap.CompressFormat.PNG, 100, os);
photobyte= os.toByteArray();