Added in API level 5

ContentProviderOperation.Builder


public static class ContentProviderOperation.Builder
extends Object

java.lang.Object
   ↳ android.content.ContentProviderOperation.Builder


Used to add parameters to a ContentProviderOperation. The Builder is first created by calling ContentProviderOperation#newInsert(android.net.Uri), ContentProviderOperation#newUpdate(android.net.Uri), ContentProviderOperation#newDelete(android.net.Uri) or ContentProviderOperation#newAssertQuery(Uri). The withXXX methods can then be used to add parameters to the builder. See the specific methods to find for which Builder type each is allowed. Call build() to create the ContentProviderOperation once all the parameters have been supplied.

Summary

Public methods

ContentProviderOperation build()

Create a ContentProviderOperation from this Builder.

ContentProviderOperation.Builder withExceptionAllowed(boolean exceptionAllowed)

If set to true, this operation allows subsequent operations to continue even if this operation throws an exception.

ContentProviderOperation.Builder withExpectedCount(int count)

If set then if the number of rows affected by this operation does not match this count OperationApplicationException will be throw.

ContentProviderOperation.Builder withExtra(String key, Object value)

Configure the given extra to use for this operation.

ContentProviderOperation.Builder withExtraBackReference(String key, int fromIndex, String fromKey)

Configure the given extra to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withExtraBackReference(String key, int fromIndex)

Configure the given extra to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withExtras(Bundle extras)

Configure the extras to use for this operation.

ContentProviderOperation.Builder withSelection(String selection, String[] selectionArgs)

Configure the selection and selection arguments to use for this operation.

ContentProviderOperation.Builder withSelectionBackReference(int index, int fromIndex)

Configure the given selection argument to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withSelectionBackReference(int index, int fromIndex, String fromKey)

Configure the given selection argument to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withValue(String key, Object value)

Configure the given value to use for this operation.

ContentProviderOperation.Builder withValueBackReference(String key, int fromIndex, String fromKey)

Configure the given value to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withValueBackReference(String key, int fromIndex)

Configure the given value to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withValueBackReferences(ContentValues backReferences)

Configure the given values to be dynamically overwritten using the result of a previous operation.

ContentProviderOperation.Builder withValues(ContentValues values)

Configure the values to use for this operation.

ContentProviderOperation.Builder withYieldAllowed(boolean yieldAllowed)

If set to true then the operation allows yielding the database to other transactions if the database is contended.

Inherited methods

Public methods

build

Added in API level 5
public ContentProviderOperation build ()

Create a ContentProviderOperation from this Builder.

Returns
ContentProviderOperation This value cannot be null.

withExceptionAllowed

Added in API level 30
public ContentProviderOperation.Builder withExceptionAllowed (boolean exceptionAllowed)

If set to true, this operation allows subsequent operations to continue even if this operation throws an exception. When true, any encountered exception is returned via ContentProviderResult#exception.

Parameters
exceptionAllowed boolean

Returns
ContentProviderOperation.Builder This value cannot be null.

withExpectedCount

Added in API level 5
public ContentProviderOperation.Builder withExpectedCount (int count)

If set then if the number of rows affected by this operation does not match this count OperationApplicationException will be throw. This can only be used with builders of type update, delete, or assert.

Parameters
count int

Returns
ContentProviderOperation.Builder this builder, to allow for chaining. This value cannot be null.

withExtra

Added in API level 30
public ContentProviderOperation.Builder withExtra (String key, 
                Object value)

Configure the given extra to use for this operation. This method will replace any previously defined extras for this key.

Parameters
key String: the key indicating which extra to configure This value cannot be null.

value Object: This value may be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withExtraBackReference

Added in API level 30
public ContentProviderOperation.Builder withExtraBackReference (String key, 
                int fromIndex, 
                String fromKey)

Configure the given extra to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined extras for this key.

Parameters
key String: the key indicating which extra to configure This value cannot be null.

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the extra

fromKey String: the key of indicating which ContentProviderResult#extras value should overwrite the extra This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withExtraBackReference

Added in API level 30
public ContentProviderOperation.Builder withExtraBackReference (String key, 
                int fromIndex)

Configure the given extra to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined extras for this key.

Parameters
key String: the key indicating which extra to configure This value cannot be null.

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the extra

Returns
ContentProviderOperation.Builder This value cannot be null.

withExtras

Added in API level 30
public ContentProviderOperation.Builder withExtras (Bundle extras)

Configure the extras to use for this operation. This method will replace any previously defined values for the contained keys, but it will not replace any back-reference requests.

Any value may be dynamically overwritten using the result of a previous operation by using methods such as withExtraBackReference(java.lang.String, int).

Parameters
extras Bundle: This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withSelection

Added in API level 5
public ContentProviderOperation.Builder withSelection (String selection, 
                String[] selectionArgs)

Configure the selection and selection arguments to use for this operation. This method will replace any previously defined selection and selection arguments, but it will not replace any back-reference requests.

An occurrence of ? in the selection will be replaced with the corresponding selection argument when the operation is executed.

Any selection argument may be dynamically overwritten using the result of a previous operation by using methods such as withSelectionBackReference(int, int).

Parameters
selection String: This value may be null.

selectionArgs String: This value may be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withSelectionBackReference

Added in API level 5
public ContentProviderOperation.Builder withSelectionBackReference (int index, 
                int fromIndex)

Configure the given selection argument to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined selection argument at this index.

Parameters
index int: the index indicating which selection argument to configure

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the selection argument

Returns
ContentProviderOperation.Builder This value cannot be null.

withSelectionBackReference

Added in API level 30
public ContentProviderOperation.Builder withSelectionBackReference (int index, 
                int fromIndex, 
                String fromKey)

Configure the given selection argument to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined selection argument at this index.

Parameters
index int: the index indicating which selection argument to configure

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the selection argument

fromKey String: the key of indicating which ContentProviderResult#extras value should overwrite the selection argument This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withValue

Added in API level 5
public ContentProviderOperation.Builder withValue (String key, 
                Object value)

Configure the given value to use for this operation. This method will replace any previously defined value for this key.

Parameters
key String: the key indicating which value to configure This value cannot be null.

value Object: This value may be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withValueBackReference

Added in API level 30
public ContentProviderOperation.Builder withValueBackReference (String key, 
                int fromIndex, 
                String fromKey)

Configure the given value to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined value for this key.

Parameters
key String: the key indicating which value to configure This value cannot be null.

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the value

fromKey String: the key of indicating which ContentProviderResult#extras value should overwrite the value This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withValueBackReference

Added in API level 5
public ContentProviderOperation.Builder withValueBackReference (String key, 
                int fromIndex)

Configure the given value to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined value for this key.

Parameters
key String: the key indicating which value to configure This value cannot be null.

fromIndex int: the index indicating which historical ContentProviderResult should overwrite the value

Returns
ContentProviderOperation.Builder This value cannot be null.

withValueBackReferences

Added in API level 5
public ContentProviderOperation.Builder withValueBackReferences (ContentValues backReferences)

Configure the given values to be dynamically overwritten using the result of a previous operation. This method will replace any previously defined values for these keys.

Parameters
backReferences ContentValues: set of values where the key indicates which value to configure and the value the index indicating which historical ContentProviderResult should overwrite the value This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withValues

Added in API level 5
public ContentProviderOperation.Builder withValues (ContentValues values)

Configure the values to use for this operation. This method will replace any previously defined values for the contained keys, but it will not replace any back-reference requests.

Any value may be dynamically overwritten using the result of a previous operation by using methods such as withValueBackReference(java.lang.String, int).

Parameters
values ContentValues: This value cannot be null.

Returns
ContentProviderOperation.Builder This value cannot be null.

withYieldAllowed

Added in API level 5
public ContentProviderOperation.Builder withYieldAllowed (boolean yieldAllowed)

If set to true then the operation allows yielding the database to other transactions if the database is contended.

Parameters
yieldAllowed boolean

Returns
ContentProviderOperation.Builder this builder, to allow for chaining. This value cannot be null.