diff options
author | Fred Quintana <fredq@google.com> | 2009-05-04 16:01:15 -0700 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2009-05-15 13:55:32 -0700 |
commit | ce31b2361db630cf1347fa42dd77e610a4eeb96d (patch) | |
tree | 9c44f860550818ad489010c40547370daa9bc6c2 /core/java/android/content/ContentProvider.java | |
parent | e18b02cc2c142fe5cf4a1c9753822876931b7da8 (diff) | |
download | frameworks_base-ce31b2361db630cf1347fa42dd77e610a4eeb96d.zip frameworks_base-ce31b2361db630cf1347fa42dd77e610a4eeb96d.tar.gz frameworks_base-ce31b2361db630cf1347fa42dd77e610a4eeb96d.tar.bz2 |
enhance ContentProvider with the ability to perform batch operations
Diffstat (limited to 'core/java/android/content/ContentProvider.java')
-rw-r--r-- | core/java/android/content/ContentProvider.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index 3a8de6e..c204dda 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -629,4 +629,26 @@ public abstract class ContentProvider implements ComponentCallbacks { ContentProvider.this.onCreate(); } } -} + + /** + * Applies each of the {@link ContentProviderOperation} objects and returns an array + * of their results. Passes through OperationApplicationException, which may be thrown + * by the call to {@link ContentProviderOperation#apply}. + * If all the applications succeed then a {@link ContentProviderResult} array with the + * same number of elements as the operations will be returned. It is implementation-specific + * how many, if any, operations will have been successfully applied if a call to + * apply results in a {@link OperationApplicationException}. + * @param operations the operations to apply + * @return the results of the applications + * @throws OperationApplicationException thrown if an application fails. + * See {@link ContentProviderOperation#apply} for more information. + */ + public ContentProviderResult[] applyBatch(ContentProviderOperation[] operations) + throws OperationApplicationException { + ContentProviderResult[] results = new ContentProviderResult[operations.length]; + for (int i = 0; i < operations.length; i++) { + results[i] = operations[i].apply(this, results, i); + } + return results; + } +}
\ No newline at end of file |