java.lang.Object | |
↳ | android.provider.ContactsContract.StreamItems |
Constants for the stream_items table, which contains social stream updates from the user's contact list.
Only a certain number of stream items will ever be stored under a given raw contact.
Users of this API can query CONTENT_LIMIT_URI
to
determine this limit, and should restrict the number of items inserted in any given
transaction correspondingly. Insertion of more items beyond the limit will
automatically lead to deletion of the oldest items, by TIMESTAMP
.
Access to the social stream through these URIs requires additional permissions beyond the read/write contact permissions required by the provider. Querying for social stream data requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
The content URIs to the insert, update and delete operations are required to have the account
information matching that of the owning raw contact as query parameters, namely
ACCOUNT_TYPE
and ACCOUNT_NAME
.
DATA_SET
isn't required.
Social stream updates are always associated with a raw contact. There are a couple of ways to insert these entries.
CONTENT_DIRECTORY
sub-path of a raw contact:ContentValues values = new ContentValues(); values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); values.put(StreamItems.TIMESTAMP, timestamp); values.put(StreamItems.COMMENTS, "3 people reshared this"); Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, rawContactId); builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); Uri streamItemUri = getContentResolver().insert(builder.build(), values); long streamItemId = ContentUris.parseId(streamItemUri);
CONTENT_URI
:ContentValues values = new ContentValues(); values.put(StreamItems.RAW_CONTACT_ID, rawContactId); values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); values.put(StreamItems.TIMESTAMP, timestamp); values.put(StreamItems.COMMENTS, "3 people reshared this"); Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); Uri streamItemUri = getContentResolver().insert(builder.build(), values); long streamItemId = ContentUris.parseId(streamItemUri);
Once a ContactsContract.Contacts.StreamItems
entry has been inserted, photos associated with that
social update can be inserted. For example, after one of the insertions above,
photos could be added to the stream item in one of the following ways:
values.clear(); values.put(StreamItemPhotos.SORT_INDEX, 1); values.put(StreamItemPhotos.PHOTO, photoData); getContentResolver().insert(Uri.withAppendedPath( ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
CONTENT_PHOTO_URI
:values.clear(); values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); values.put(StreamItemPhotos.SORT_INDEX, 1); values.put(StreamItemPhotos.PHOTO, photoData); getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
Note that this latter form allows the insertion of a stream item and its
photos in a single transaction, by using ContentProviderOperation
with
back references to populate the stream item ID in the ContentValues
.
CONTENT_URI
URI. Only social stream entries that were
created by the calling package can be updated.CONTENT_URI
URI. Only social stream entries that were
created by the calling package can be deleted.Cursor c = getContentResolver().query(Uri.withAppendedPath( ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), Contacts.StreamItems.CONTENT_DIRECTORY), null, null, null, null);
Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() .appendPath(lookupKey) .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), null, null, null, null);
Cursor c = getContentResolver().query(Uri.withAppendedPath( ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), RawContacts.StreamItems.CONTENT_DIRECTORY)), null, null, null, null);
Cursor c = getContentResolver().query(ContentUris.withAppendedId( StreamItems.CONTENT_URI, streamItemId), null, null, null, null);
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ContactsContract.StreamItems.StreamItemPhotos | A sub-directory of a single stream item entry that contains all of its photo rows. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | CONTENT_ITEM_TYPE | The MIME type of a single stream item. | |||||||||
String | CONTENT_TYPE | The MIME type of a directory of stream items. | |||||||||
String | MAX_ITEMS | Queries to CONTENT_LIMIT_URI will
contain this column, with the value indicating the maximum number of
stream items that will be stored under any single raw contact. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.provider.BaseColumns
| |||||||||||
From interface
android.provider.ContactsContract.StreamItemsColumns
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CONTENT_LIMIT_URI | This URI allows the caller to query for the maximum number of stream items that will be stored under any single raw contact. | ||||||||||
CONTENT_PHOTO_URI | A content:// style URI for the photos stored in a sub-table underneath stream items. |
||||||||||
CONTENT_URI | The content:// style URI for this table, which handles social network stream updates for the user's contacts. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The MIME type of a single stream item.
The MIME type of a directory of stream items.
Queries to CONTENT_LIMIT_URI
will
contain this column, with the value indicating the maximum number of
stream items that will be stored under any single raw contact.
This URI allows the caller to query for the maximum number of stream items that will be stored under any single raw contact.
A content:// style URI for the photos stored in a sub-table underneath
stream items. This is only used for inserts, and updates - queries and deletes
for photos should be performed by appending
CONTENT_DIRECTORY
path to URIs for a
specific stream item.
When using this URI, the stream item ID for the photo(s) must be identified
in the ContentValues
passed in.
The content:// style URI for this table, which handles social network stream updates for the user's contacts.