Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#inhmethods)

# ContentProviderOperation.Builder

*** ** * ** ***


`
public
static


class
ContentProviderOperation.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.ContentProviderOperation.Builder |

<br />

*** ** * ** ***

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

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/content/ContentProviderOperation` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#build()() ` Create a ContentProviderOperation from this `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder`. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExceptionAllowed(boolean)(boolean exceptionAllowed) ` If set to true, this operation allows subsequent operations to continue even if this operation throws an exception. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExpectedCount(int)(int count) ` If set then if the number of rows affected by this operation does not match this count `https://developer.android.com/reference/android/content/OperationApplicationException` will be throw. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExtra(java.lang.String,%20java.lang.Object)(https://developer.android.com/reference/java/lang/String key, https://developer.android.com/reference/java/lang/Object value) ` Configure the given extra to use for this operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExtraBackReference(java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/java/lang/String key, int fromIndex, https://developer.android.com/reference/java/lang/String fromKey) ` Configure the given extra to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExtraBackReference(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String key, int fromIndex) ` Configure the given extra to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExtras(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle extras) ` Configure the extras to use for this operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withSelection(java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs) ` Configure the selection and selection arguments to use for this operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withSelectionBackReference(int,%20int)(int index, int fromIndex) ` Configure the given selection argument to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withSelectionBackReference(int,%20int,%20java.lang.String)(int index, int fromIndex, https://developer.android.com/reference/java/lang/String fromKey) ` Configure the given selection argument to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValue(java.lang.String,%20java.lang.Object)(https://developer.android.com/reference/java/lang/String key, https://developer.android.com/reference/java/lang/Object value) ` Configure the given value to use for this operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValueBackReference(java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/java/lang/String key, int fromIndex, https://developer.android.com/reference/java/lang/String fromKey) ` Configure the given value to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValueBackReference(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String key, int fromIndex) ` Configure the given value to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValueBackReferences(android.content.ContentValues)(https://developer.android.com/reference/android/content/ContentValues backReferences) ` Configure the given values to be dynamically overwritten using the result of a previous operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValues(android.content.ContentValues)(https://developer.android.com/reference/android/content/ContentValues values) ` Configure the values to use for this operation. |
| ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | ` https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withYieldAllowed(boolean)(boolean yieldAllowed) ` If set to true then the operation allows yielding the database to other transactions if the database is contended. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### build

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ContentProviderOperation build ()
```

Create a ContentProviderOperation from this `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation` | This value cannot be `null`. <br /> |

### withExceptionAllowed

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/android/content/ContentProviderResult#exception`.

<br />

| Parameters ||
|---|---|
| `exceptionAllowed` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withExpectedCount

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ContentProviderOperation.Builder withExpectedCount (int count)
```

If set then if the number of rows affected by this operation does not match
this count `https://developer.android.com/reference/android/content/OperationApplicationException` will be throw.
This can only be used with builders of type update, delete, or assert.

<br />

| Parameters ||
|---|---|
| `count` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | this builder, to allow for chaining. This value cannot be `null`. <br /> |

### withExtra

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which extra to configure. This value cannot be `null`. <br /> |
| `value` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withExtraBackReference

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which extra to configure. This value cannot be `null`. <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the extra <br /> |
| `fromKey` | `String`: the key of indicating which `https://developer.android.com/reference/android/content/ContentProviderResult#extras` value should overwrite the extra. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withExtraBackReference

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which extra to configure. This value cannot be `null`. <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the extra <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withExtras

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withExtraBackReference(java.lang.String,%20int)`.

<br />

| Parameters ||
|---|---|
| `extras` | `Bundle`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withSelection

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withSelectionBackReference(int,%20int)`.

<br />

| Parameters ||
|---|---|
| `selection` | `String`: This value may be `null`. <br /> |
| `selectionArgs` | `String`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withSelectionBackReference

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index indicating which selection argument to configure <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the selection argument <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withSelectionBackReference

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index indicating which selection argument to configure <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the selection argument <br /> |
| `fromKey` | `String`: the key of indicating which `https://developer.android.com/reference/android/content/ContentProviderResult#extras` value should overwrite the selection argument. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withValue

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which value to configure. This value cannot be `null`. <br /> |
| `value` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withValueBackReference

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which value to configure. This value cannot be `null`. <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the value <br /> |
| `fromKey` | `String`: the key of indicating which `https://developer.android.com/reference/android/content/ContentProviderResult#extras` value should overwrite the value. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withValueBackReference

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `key` | `String`: the key indicating which value to configure. This value cannot be `null`. <br /> |
| `fromIndex` | `int`: the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the value <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withValueBackReferences

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `backReferences` | `ContentValues`: set of values where the key indicates which value to configure and the value the index indicating which historical `https://developer.android.com/reference/android/content/ContentProviderResult` should overwrite the value. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withValues

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/android/content/ContentProviderOperation.Builder#withValueBackReference(java.lang.String,%20int)`.

<br />

| Parameters ||
|---|---|
| `values` | `ContentValues`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | This value cannot be `null`. <br /> |

### withYieldAllowed

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `yieldAllowed` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentProviderOperation.Builder` | this builder, to allow for chaining. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#yieldIfContendedSafely()`