/**@class android.provider.ContactsContract.StreamItems implements android.provider.BaseColumns implements android.provider.ContactsContract.StreamItemsColumns @extends java.lang.Object <p> Constants for the stream_items table, which contains social stream updates from the user's contact list. </p> <p> Only a certain number of stream items will ever be stored under a given raw contact. Users of this API can query {@link android.provider.ContactsContract.StreamItems#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 {@link android.provider.ContactsContract.StreamItems#TIMESTAMP}. </p> <p> 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. </p> <h3>Account check</h3> <p> 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 {@link android.provider.ContactsContract.RawContacts#ACCOUNT_TYPE} and {@link android.provider.ContactsContract.RawContacts#ACCOUNT_NAME}. {@link android.provider.ContactsContract.RawContacts#DATA_SET} isn't required. </p> <h3>Operations</h3> <dl> <dt><b>Insert</b></dt> <dd> <p>Social stream updates are always associated with a raw contact. There are a couple of ways to insert these entries. <dl> <dt>Via the {@link android.provider.ContactsContract.RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> <dd> <pre> 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); </pre> </dd> <dt>Via {@link android.provider.ContactsContract.StreamItems#CONTENT_URI}:</dt> <dd> <pre> 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); </pre> </dd> </dl> </dd> </p> <p> Once a {@link android.provider.ContactsContract.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: <dl> <dt>Via a URI including the stream item ID:</dt> <dd> <pre> 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); </pre> </dd> <dt>Via {@link android.provider.ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> <dd> <pre> 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); </pre> <p>Note that this latter form allows the insertion of a stream item and its photos in a single transaction, by using {@link ContentProviderOperation} with back references to populate the stream item ID in the {@link ContentValues}. </dd> </dl> </p> </dd> <dt><b>Update</b></dt> <dd>Updates can be performed by appending the stream item ID to the {@link android.provider.ContactsContract.StreamItems#CONTENT_URI} URI. Only social stream entries that were created by the calling package can be updated.</dd> <dt><b>Delete</b></dt> <dd>Deletes can be performed by appending the stream item ID to the {@link android.provider.ContactsContract.StreamItems#CONTENT_URI} URI. Only social stream entries that were created by the calling package can be deleted.</dd> <dt><b>Query</b></dt> <dl> <dt>Finding all social stream updates for a given contact</dt> <dd>By Contact ID: <pre> Cursor c = getContentResolver().query(Uri.withAppendedPath( ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), Contacts.StreamItems.CONTENT_DIRECTORY), null, null, null, null); </pre> </dd> <dd>By lookup key: <pre> Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() .appendPath(lookupKey) .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), null, null, null, null); </pre> </dd> <dt>Finding all social stream updates for a given raw contact</dt> <dd> <pre> Cursor c = getContentResolver().query(Uri.withAppendedPath( ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), RawContacts.StreamItems.CONTENT_DIRECTORY)), null, null, null, null); </pre> </dd> <dt>Querying for a specific stream item by ID</dt> <dd> <pre> Cursor c = getContentResolver().query(ContentUris.withAppendedId( StreamItems.CONTENT_URI, streamItemId), null, null, null, null); </pre> </dd> </dl> @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. @removed */ var StreamItems = { /** The content:// style URI for this table, which handles social network stream updates for the user's contacts. @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ CONTENT_URI : "null", /** <p> 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 {@link android.provider.ContactsContract.StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a specific stream item. </p> <p> When using this URI, the stream item ID for the photo(s) must be identified in the {@link ContentValues} passed in. </p> @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ CONTENT_PHOTO_URI : "null", /** This URI allows the caller to query for the maximum number of stream items that will be stored under any single raw contact. @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ CONTENT_LIMIT_URI : "null", /** The MIME type of a directory of stream items. @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ CONTENT_TYPE : "vnd.android.cursor.dir/stream_item", /** The MIME type of a single stream item. @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ CONTENT_ITEM_TYPE : "vnd.android.cursor.item/stream_item", /** Queries to {@link android.provider.ContactsContract.StreamItems#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. @deprecated - Do not use. This will not be supported in the future. In the future, cursors returned from related queries will be empty. */ MAX_ITEMS : "max_items", };