Android APIs
public class

ContentProviderOperation

extends Object
implements Parcelable
java.lang.Object
   ↳ android.content.ContentProviderOperation

Class Overview

Represents a single operation to be performed as part of a batch of operations.

Summary

Nested Classes
class ContentProviderOperation.Builder Used to add parameters to a ContentProviderOperation
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<ContentProviderOperation> CREATOR
Public Methods
ContentProviderResult apply(ContentProvider provider, ContentProviderResult[] backRefs, int numBackRefs)
Applies this operation using the given provider.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Uri getUri()
Gets the Uri for the target of the operation.
boolean isAssertQuery()
Returns true if the operation represents an assert query.
boolean isDelete()
Returns true if the operation represents a deletion.
boolean isInsert()
Returns true if the operation represents an insertion.
boolean isReadOperation()
Returns true if the operation represents an assert query.
boolean isUpdate()
Returns true if the operation represents an update.
boolean isWriteOperation()
Returns true if the operation represents an insertion, deletion, or update.
boolean isYieldAllowed()
Returns true if the operation allows yielding the database to other transactions if the database is contended.
static ContentProviderOperation.Builder newAssertQuery(Uri uri)
Create a ContentProviderOperation.Builder suitable for building a ContentProviderOperation to assert a set of values as provided through withValues(ContentValues).
static ContentProviderOperation.Builder newDelete(Uri uri)
Create a ContentProviderOperation.Builder suitable for building a delete ContentProviderOperation.
static ContentProviderOperation.Builder newInsert(Uri uri)
Create a ContentProviderOperation.Builder suitable for building an insert ContentProviderOperation.
static ContentProviderOperation.Builder newUpdate(Uri uri)
Create a ContentProviderOperation.Builder suitable for building an update ContentProviderOperation.
String[] resolveSelectionArgsBackReferences(ContentProviderResult[] backRefs, int numBackRefs)
The Selection Arguments back references are represented as a Map of Integer->Integer where the key is an index into the selection argument array (see withSelection(String, String[])) and the value is the index of the previous result that should be used for that selection argument array slot.
ContentValues resolveValueBackReferences(ContentProviderResult[] backRefs, int numBackRefs)
The ContentValues back references are represented as a ContentValues object where the key refers to a column and the value is an index of the back reference whose valued should be associated with the column.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<ContentProviderOperation> CREATOR

Added in API level 5

Public Methods

public ContentProviderResult apply (ContentProvider provider, ContentProviderResult[] backRefs, int numBackRefs)

Added in API level 5

Applies this operation using the given provider. The backRefs array is used to resolve any back references that were requested using withValueBackReferences(ContentValues) and withSelectionBackReference(int, int).

Parameters
provider ContentProvider: the ContentProvider on which this batch is applied
backRefs ContentProviderResult: a ContentProviderResult array that will be consulted to resolve any requested back references.
numBackRefs int: the number of valid results on the backRefs array.
Returns
ContentProviderResult a ContentProviderResult that contains either the Uri of the inserted row if this was an insert otherwise the number of rows affected.
Throws
OperationApplicationException thrown if either the insert fails or if the number of rows affected didn't match the expected count

public int describeContents ()

Added in API level 5

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
int a bitmask indicating the set of special object types marshalled by the Parcelable.

public Uri getUri ()

Added in API level 5

Gets the Uri for the target of the operation.

Returns
Uri

public boolean isAssertQuery ()

Added in API level 23

Returns true if the operation represents an assert query.

Returns
boolean

public boolean isDelete ()

Added in API level 23

Returns true if the operation represents a deletion.

Returns
boolean

See also:

public boolean isInsert ()

Added in API level 23

Returns true if the operation represents an insertion.

Returns
boolean

See also:

public boolean isReadOperation ()

Added in API level 5

Returns true if the operation represents an assert query.

Returns
boolean

See also:

public boolean isUpdate ()

Added in API level 23

Returns true if the operation represents an update.

Returns
boolean

See also:

public boolean isWriteOperation ()

Added in API level 5

Returns true if the operation represents an insertion, deletion, or update.

Returns
boolean

public boolean isYieldAllowed ()

Added in API level 5

Returns true if the operation allows yielding the database to other transactions if the database is contended.

Returns
boolean

public static ContentProviderOperation.Builder newAssertQuery (Uri uri)

Added in API level 5

Create a ContentProviderOperation.Builder suitable for building a ContentProviderOperation to assert a set of values as provided through withValues(ContentValues).

Parameters
uri Uri
Returns
ContentProviderOperation.Builder

public static ContentProviderOperation.Builder newDelete (Uri uri)

Added in API level 5

Create a ContentProviderOperation.Builder suitable for building a delete ContentProviderOperation.

Parameters
uri Uri: The Uri that is the target of the delete.
Returns
ContentProviderOperation.Builder a ContentProviderOperation.Builder

public static ContentProviderOperation.Builder newInsert (Uri uri)

Added in API level 5

Create a ContentProviderOperation.Builder suitable for building an insert ContentProviderOperation.

Parameters
uri Uri: The Uri that is the target of the insert.
Returns
ContentProviderOperation.Builder a ContentProviderOperation.Builder

public static ContentProviderOperation.Builder newUpdate (Uri uri)

Added in API level 5

Create a ContentProviderOperation.Builder suitable for building an update ContentProviderOperation.

Parameters
uri Uri: The Uri that is the target of the update.
Returns
ContentProviderOperation.Builder a ContentProviderOperation.Builder

public String[] resolveSelectionArgsBackReferences (ContentProviderResult[] backRefs, int numBackRefs)

Added in API level 5

The Selection Arguments back references are represented as a Map of Integer->Integer where the key is an index into the selection argument array (see withSelection(String, String[])) and the value is the index of the previous result that should be used for that selection argument array slot.

This is intended to be a private method but it is exposed for unit testing purposes

Parameters
backRefs ContentProviderResult: an array of previous results
numBackRefs int: the number of valid previous results in backRefs
Returns
String[] the ContentValues that should be used in this operation application after expansion of back references. This can be called if either mValues or mValuesBackReferences is null

public ContentValues resolveValueBackReferences (ContentProviderResult[] backRefs, int numBackRefs)

Added in API level 5

The ContentValues back references are represented as a ContentValues object where the key refers to a column and the value is an index of the back reference whose valued should be associated with the column.

This is intended to be a private method but it is exposed for unit testing purposes

Parameters
backRefs ContentProviderResult: an array of previous results
numBackRefs int: the number of valid previous results in backRefs
Returns
ContentValues the ContentValues that should be used in this operation application after expansion of back references. This can be called if either mValues or mValuesBackReferences is null

public String toString ()

Added in API level 5

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
String a printable representation of this object.

public void writeToParcel (Parcel dest, int flags)

Added in API level 5

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.