public static final class ContactsContract.Contacts.Photo extends Object implements BaseColumns, ContactsContract.DataColumnsWithJoins
Usage example:
public InputStream openPhoto(long contactId) { Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); Cursor cursor = getContentResolver().query(photoUri, new String[] {Contacts.Photo.PHOTO}, null, null, null); if (cursor == null) { return null; } try { if (cursor.moveToFirst()) { byte[] data = cursor.getBlob(0); if (data != null) { return new ByteArrayInputStream(data); } } } finally { cursor.close(); } return null; }
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; } }
You may also consider using the convenience method
ContactsContract.Contacts.openContactPhotoInputStream(ContentResolver, Uri, boolean)
to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
This directory can be used either with a ContactsContract.Contacts.CONTENT_URI
or
ContactsContract.Contacts.CONTENT_LOOKUP_URI
.
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_DIRECTORY
The directory twig for this sub-table
|
static String |
DISPLAY_PHOTO
The directory twig for retrieving the full-size display photo.
|
static String |
PHOTO
Thumbnail photo of the raw contact.
|
static String |
PHOTO_FILE_ID
Full-size photo file ID of the raw contact.
|
_COUNT, _ID
DATA_VERSION, DATA1, DATA10, DATA11, DATA12, DATA13, DATA14, DATA15, DATA2, DATA3, DATA4, DATA5, DATA6, DATA7, DATA8, DATA9, IS_PRIMARY, IS_READ_ONLY, IS_SUPER_PRIMARY, MIMETYPE, RAW_CONTACT_ID, RES_PACKAGE, SYNC1, SYNC2, SYNC3, SYNC4
AVAILABLE, AWAY, CAPABILITY_HAS_CAMERA, CAPABILITY_HAS_VIDEO, CAPABILITY_HAS_VOICE, CHAT_CAPABILITY, DO_NOT_DISTURB, IDLE, INVISIBLE, OFFLINE, PRESENCE, PRESENCE_CUSTOM_STATUS, PRESENCE_STATUS, STATUS, STATUS_ICON, STATUS_LABEL, STATUS_RES_PACKAGE, STATUS_TIMESTAMP
ACCOUNT_TYPE_AND_DATA_SET, AGGREGATION_MODE, CONTACT_ID, DATA_SET, DELETED, NAME_VERIFIED, RAW_CONTACT_IS_READ_ONLY, RAW_CONTACT_IS_USER_PROFILE
DISPLAY_NAME, HAS_PHONE_NUMBER, IN_VISIBLE_GROUP, IS_USER_PROFILE, LOOKUP_KEY, NAME_RAW_CONTACT_ID, PHOTO_ID, PHOTO_THUMBNAIL_URI, PHOTO_URI
DISPLAY_NAME_ALTERNATIVE, DISPLAY_NAME_PRIMARY, DISPLAY_NAME_SOURCE, PHONETIC_NAME, PHONETIC_NAME_STYLE, SORT_KEY_ALTERNATIVE, SORT_KEY_PRIMARY
CUSTOM_RINGTONE, LAST_TIME_CONTACTED, SEND_TO_VOICEMAIL, STARRED, TIMES_CONTACTED
CONTACT_CHAT_CAPABILITY, CONTACT_PRESENCE, CONTACT_STATUS, CONTACT_STATUS_ICON, CONTACT_STATUS_LABEL, CONTACT_STATUS_RES_PACKAGE, CONTACT_STATUS_TIMESTAMP
public static final String CONTENT_DIRECTORY
public static final String DISPLAY_PHOTO
public static final String PHOTO_FILE_ID
ContactsContract.DisplayPhoto
.
Type: NUMBER
public static final String PHOTO
BitmapFactory
.
Type: BLOB