1
我有圖像URI。現在我想在Android中設置爲照片我如何開始? 這裏是我的功能在Android中設置圖片爲聯繫人照片
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{id}, null);
if(cursor.moveToNext())
{
mContactName = cursor.getString(cursor.getColumnIndex((ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
mPhotoUri = Uri.withAppendedPath(result, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
mContactNumber = cursor.getString(cursor.getColumnIndex((ContactsContract.CommonDataKinds.Phone.NUMBER)));
Log.i("Dante", "ContactName = "+ mContactName );
Log.i("Dante", "mContactNumber ="+mContactNumber);
Log.i("Dante", " PhotoURI "+mPhotoUri);
}
ContentResolver cr = mContext.getContentResolver();
int i = collagelistadaper.getItemPositon();
ContentValues values = new ContentValues();
values.put(ContactsContract.Contacts.Photo.CONTENT_DIRECTORY, Uri.fromFile(quiltFolder.listFiles()[i]).toString()); //ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValue(ContactsContract.Contacts.Photo.CONTENT_DIRECTORY, values);
Uri result1 = cr.insert(ContactsContract.Data.CONTENT_URI ,values);
// getContentResolver().update(mPhotoUri,values,null,null);
mPhotoUri = Uri.withAppendedPath(result,ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
易於爲餡餅和工程就像一個魅力。謝謝。 – dazed