IT. Expert System.

Android Reference

ContactsContract.StreamItems


android.provider

Class ContactsContract.StreamItems

  • All Implemented Interfaces:
    BaseColumns, ContactsContract.StreamItemsColumns
    Enclosing class:
    ContactsContract


    public static final class ContactsContract.StreamItems
    extends Object
    implements BaseColumns, ContactsContract.StreamItemsColumns

    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 ContactsContract.StreamItemsColumns.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 ContactsContract.SyncColumns.ACCOUNT_TYPE and ContactsContract.SyncColumns.ACCOUNT_NAME. ContactsContract.RawContactsColumns.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 ContactsContract.RawContacts.StreamItems.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 ContactsContract.Contacts.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 ContactsContract.Contacts.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 ContactsContract.Contacts.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);
     
    • Field Detail

      • CONTENT_URI

        public static final Uri CONTENT_URI
        The content:// style URI for this table, which handles social network stream updates for the user's contacts.
      • CONTENT_PHOTO_URI

        public static final Uri CONTENT_PHOTO_URI

        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 ContactsContract.StreamItems.StreamItemPhotos.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.

      • CONTENT_LIMIT_URI

        public static final Uri 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.
      • MAX_ITEMS

        public static final 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.
        See Also:
        Constant Field Values


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1938 / . Delta: 0.00731 с