0

i am setting contact image which is in the sd card,and through my application i am trying to diplay it in a list adapter.I am able to get the image uri properly. but when i am trying to set the

img.setImageURI(uri); 

some times i am getting file not found exception.Even problem with converting the uri into bitmap.I have four contacts in that 2 contact with image is displaying properly,remaining two i am getting file not found exception.please help.

V I J E S H
  • 7,464
  • 10
  • 29
  • 37

1 Answers1

0

See this link https://stackoverflow.com/a/4240238/1441666

public static Bitmap loadContactPhoto(ContentResolver cr, long  id) {
    Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
    InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
    if (input == null) {
        return null;
    }
    return BitmapFactory.decodeStream(input);
}
Community
  • 1
  • 1
Nirali
  • 13,571
  • 6
  • 40
  • 53
  • hey. i am getting the contact image uri like "content: content://com.android.contacts/contacts/7/photo". Its telling this file not found exception – V I J E S H Jul 19 '12 at 09:28