1

I want to get photo from contacts, if some contacts don't have photo to return default photo(just silhouette), how can I do that? Thanks in advance, Wolf.

Wolf87
  • 540
  • 3
  • 11
  • 29
  • refer this link http://stackoverflow.com/questions/5332333/android-problem-getting-contacts-photo-from-data-email-query – Abhi Jan 23 '12 at 08:17

1 Answers1

0

You can use ContactsContract.Contacts.Photo to get the picture for the specified contact.

Full example from the above documentation link:

public InputStream openDisplayPhoto(long contactId) {
     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
     Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
     try {
         AssetFileDescriptor fd =
             getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
         return fd.createInputStream();
     } catch (IOException e) {
         return null;
     }
 }
Adrian Fâciu
  • 12,414
  • 3
  • 53
  • 68