Android APIs
public static final class

ContactsContract.StreamItems

extends Object
implements BaseColumns ContactsContract.StreamItemsColumns
java.lang.Object
   ↳ android.provider.ContactsContract.StreamItems

This class was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

Class Overview

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.

Account check

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.

Operations

Insert

Social stream updates are always associated with a raw contact. There are a couple of ways to insert these entries.

Via the 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);
 
Via 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:

Via a URI including the stream item ID:
 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);
 
Via 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.

Update
Updates can be performed by appending the stream item ID to the CONTENT_URI URI. Only social stream entries that were created by the calling package can be updated.
Delete
Deletes can be performed by appending the stream item ID to the CONTENT_URI URI. Only social stream entries that were created by the calling package can be deleted.
Query
Finding all social stream updates for a given contact
By Contact ID:
 Cursor c = getContentResolver().query(Uri.withAppendedPath(
          ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
          Contacts.StreamItems.CONTENT_DIRECTORY),
          null, null, null, null);
 
By lookup key:
 Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
          .appendPath(lookupKey)
          .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
          null, null, null, null);
 
Finding all social stream updates for a given raw contact
 Cursor c = getContentResolver().query(Uri.withAppendedPath(
          ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
          RawContacts.StreamItems.CONTENT_DIRECTORY)),
          null, null, null, null);
 
Querying for a specific stream item by ID
 Cursor c = getContentResolver().query(ContentUris.withAppendedId(
          StreamItems.CONTENT_URI, streamItemId),
          null, null, null, null);
 

Summary

Nested Classes
class ContactsContract.StreamItems.StreamItemPhotos This class was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.  
Constants
String CONTENT_ITEM_TYPE This constant was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
String CONTENT_TYPE This constant was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
String MAX_ITEMS This constant was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
[Expand]
Inherited Constants
From interface android.provider.BaseColumns
From interface android.provider.ContactsContract.StreamItemsColumns
Fields
public static final Uri CONTENT_LIMIT_URI This field was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
public static final Uri CONTENT_PHOTO_URI This field was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
public static final Uri CONTENT_URI This field was deprecated in API level 21. - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String CONTENT_ITEM_TYPE

Added in API level 15

This constant was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

The MIME type of a single stream item.

Constant Value: "vnd.android.cursor.item/stream_item"

public static final String CONTENT_TYPE

Added in API level 15

This constant was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

The MIME type of a directory of stream items.

Constant Value: "vnd.android.cursor.dir/stream_item"

public static final String MAX_ITEMS

Added in API level 15

This constant was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

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.

Constant Value: "max_items"

Fields

public static final Uri CONTENT_LIMIT_URI

Added in API level 15

This field was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

This URI allows the caller to query for the maximum number of stream items that will be stored under any single raw contact.

public static final Uri CONTENT_PHOTO_URI

Added in API level 15

This field was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

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.

public static final Uri CONTENT_URI

Added in API level 15

This field was deprecated in API level 21.
- Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty.

The content:// style URI for this table, which handles social network stream updates for the user's contacts.