@@ -3049,6 +3049,13 @@ protected interface StatusColumns {
30493049 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
30503050 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
30513051 * </p>
3052+ * <h3>Account check</h3>
3053+ * <p>
3054+ * The content URIs to the insert, update and delete operations are required to have the account
3055+ * information matching that of the owning raw contact as query parameters, namely
3056+ * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3057+ * {@link RawContacts#DATA_SET} isn't required.
3058+ * </p>
30523059 * <h3>Operations</h3>
30533060 * <dl>
30543061 * <dt><b>Insert</b></dt>
@@ -3063,9 +3070,12 @@ protected interface StatusColumns {
30633070 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
30643071 * values.put(StreamItems.TIMESTAMP, timestamp);
30653072 * values.put(StreamItems.COMMENTS, "3 people reshared this");
3066- * Uri streamItemUri = getContentResolver().insert(
3067- * Uri.withAppendedPath(ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3068- * RawContacts.StreamItems.CONTENT_DIRECTORY), values);
3073+ * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3074+ * ContentUris.appendId(builder, rawContactId);
3075+ * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3076+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3077+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3078+ * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
30693079 * long streamItemId = ContentUris.parseId(streamItemUri);
30703080 * </pre>
30713081 * </dd>
@@ -3077,7 +3087,10 @@ protected interface StatusColumns {
30773087 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
30783088 * values.put(StreamItems.TIMESTAMP, timestamp);
30793089 * values.put(StreamItems.COMMENTS, "3 people reshared this");
3080- * Uri streamItemUri = getContentResolver().insert(StreamItems.CONTENT_URI, values);
3090+ * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3091+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3092+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3093+ * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
30813094 * long streamItemId = ContentUris.parseId(streamItemUri);
30823095 *</pre>
30833096 * </dd>
@@ -3410,6 +3423,13 @@ protected interface StreamItemsColumns {
34103423 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
34113424 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
34123425 * </p>
3426+ * <h3>Account check</h3>
3427+ * <p>
3428+ * The content URIs to the insert, update and delete operations are required to have the account
3429+ * information matching that of the owning raw contact as query parameters, namely
3430+ * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3431+ * {@link RawContacts#DATA_SET} isn't required.
3432+ * </p>
34133433 * <h3>Operations</h3>
34143434 * <dl>
34153435 * <dt><b>Insert</b></dt>
@@ -3426,9 +3446,12 @@ protected interface StreamItemsColumns {
34263446 * ContentValues values = new ContentValues();
34273447 * values.put(StreamItemPhotos.SORT_INDEX, 1);
34283448 * values.put(StreamItemPhotos.PHOTO, photoData);
3429- * Uri photoUri = getContentResolver().insert(Uri.withAppendedPath(
3430- * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3431- * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), values);
3449+ * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3450+ * ContentUris.appendId(builder, streamItemId);
3451+ * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3452+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3453+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3454+ * Uri photoUri = getContentResolver().insert(builder.build(), values);
34323455 * long photoId = ContentUris.parseId(photoUri);
34333456 * </pre>
34343457 * </dd>
@@ -3439,7 +3462,10 @@ protected interface StreamItemsColumns {
34393462 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
34403463 * values.put(StreamItemPhotos.SORT_INDEX, 1);
34413464 * values.put(StreamItemPhotos.PHOTO, photoData);
3442- * Uri photoUri = getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3465+ * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3466+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3467+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3468+ * Uri photoUri = getContentResolver().insert(builder.build(), values);
34433469 * long photoId = ContentUris.parseId(photoUri);
34443470 * </pre>
34453471 * </dd>
@@ -3459,12 +3485,13 @@ protected interface StreamItemsColumns {
34593485 * <pre>
34603486 * ContentValues values = new ContentValues();
34613487 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
3462- * getContentResolver().update(
3463- * ContentUris.withAppendedId(
3464- * Uri.withAppendedPath(
3465- * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3466- * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3467- * streamItemPhotoId), values, null, null);
3488+ * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3489+ * ContentUris.appendId(builder, streamItemId);
3490+ * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3491+ * ContentUris.appendId(builder, streamItemPhotoId);
3492+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3493+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3494+ * getContentResolver().update(builder.build(), values, null, null);
34683495 * </pre>
34693496 * </dd>
34703497 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
@@ -3473,7 +3500,10 @@ protected interface StreamItemsColumns {
34733500 * ContentValues values = new ContentValues();
34743501 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
34753502 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
3476- * getContentResolver().update(StreamItems.CONTENT_PHOTO_URI, values);
3503+ * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3504+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3505+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3506+ * getContentResolver().update(builder.build(), values);
34773507 * </pre>
34783508 * </dd>
34793509 * </dl>
@@ -3489,21 +3519,24 @@ protected interface StreamItemsColumns {
34893519 * </dt>
34903520 * <dd>
34913521 * <pre>
3492- * getContentResolver().delete(
3493- * ContentUris.withAppendedId(
3494- * Uri.withAppendedPath(
3495- * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3496- * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3497- * streamItemPhotoId), null, null);
3522+ * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3523+ * ContentUris.appendId(builder, streamItemId);
3524+ * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3525+ * ContentUris.appendId(builder, streamItemPhotoId);
3526+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3527+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3528+ * getContentResolver().delete(builder.build(), null, null);
34983529 * </pre>
34993530 * </dd>
35003531 * <dt>Deleting all photos under a stream item</dt>
35013532 * <dd>
35023533 * <pre>
3503- * getContentResolver().delete(
3504- * Uri.withAppendedPath(
3505- * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3506- * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), null, null);
3534+ * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3535+ * ContentUris.appendId(builder, streamItemId);
3536+ * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3537+ * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3538+ * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3539+ * getContentResolver().delete(builder.build(), null, null);
35073540 * </pre>
35083541 * </dd>
35093542 * </dl>
0 commit comments