I am listing contacts with photo but i could not shown the photos of contacts. I get the photo uri as following:
ContentResolver cr = getContentResolver();
// Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,null, null,null );
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC");
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
photo_id = cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
Log.e("name", name);
Log.e("Photo_id", ""+photo_id);
photo = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, photo_id);
Log.e("URI", ""+photo);
image.setImageURI(photo); // Does not shown image.
...
}
}
A sample uri(printed in Log):
content://com.android.contacts/contacts/52
i do not know the reason why uri is not shown the images. please help me.