java.lang.Object | |
↳ | android.provider.ContactsContract.Contacts.Photo |
A read-only sub-directory of a single contact that contains the contact's primary photo. The photo may be stored in up to two ways - the default "photo" is a thumbnail-sized image stored directly in the data row, while the "display photo", if present, is a larger version stored as a file.
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
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 CONTENT_URI
or
CONTENT_LOOKUP_URI
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | CONTENT_DIRECTORY | The directory twig for this sub-table | |||||||||
String | DISPLAY_PHOTO | The directory twig for retrieving the full-size display photo. | |||||||||
String | PHOTO | Thumbnail photo of the raw contact. | |||||||||
String | PHOTO_FILE_ID | Full-size photo file ID of the raw contact. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.provider.BaseColumns
| |||||||||||
From interface
android.provider.ContactsContract.ContactNameColumns
| |||||||||||
From interface
android.provider.ContactsContract.ContactOptionsColumns
| |||||||||||
From interface
android.provider.ContactsContract.ContactStatusColumns
| |||||||||||
From interface
android.provider.ContactsContract.ContactsColumns
| |||||||||||
From interface
android.provider.ContactsContract.DataColumns
| |||||||||||
From interface
android.provider.ContactsContract.DataUsageStatColumns
| |||||||||||
From interface
android.provider.ContactsContract.RawContactsColumns
| |||||||||||
From interface
android.provider.ContactsContract.StatusColumns
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The directory twig for this sub-table
The directory twig for retrieving the full-size display photo.
Thumbnail photo of the raw contact. This is the raw bytes of an image
that could be inflated using BitmapFactory
.
Type: BLOB
Full-size photo file ID of the raw contact.
See ContactsContract.DisplayPhoto
.
Type: NUMBER