diff options
author | Tom Wilson <tomwilson@google.com> | 2012-02-23 15:05:02 -0800 |
---|---|---|
committer | Tom Wilson <tomwilson@google.com> | 2012-02-23 18:26:33 -0800 |
commit | 698c55f3a36fe972b381ad216dc5de3760936858 (patch) | |
tree | affd95e75f28bbb96c256c499581f610c49cfed5 /common | |
parent | ddf93921e3a7c4c41326036df7242118ffdafbb3 (diff) | |
download | android_frameworks_ex-698c55f3a36fe972b381ad216dc5de3760936858.tar.gz android_frameworks_ex-698c55f3a36fe972b381ad216dc5de3760936858.tar.bz2 android_frameworks_ex-698c55f3a36fe972b381ad216dc5de3760936858.zip |
Adding minor tweaks to SQLiteContentProvider.
Allows sub-classes to specify a max number of batch operations, and
makes this data accessible as a public method.
Change-Id: I3d1cb7b996b23e45b479613b0af4f01a8a641f04
Diffstat (limited to 'common')
-rw-r--r-- | common/java/com/android/common/content/SQLiteContentProvider.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common/java/com/android/common/content/SQLiteContentProvider.java b/common/java/com/android/common/content/SQLiteContentProvider.java index 02f1835..fb86c14 100644 --- a/common/java/com/android/common/content/SQLiteContentProvider.java +++ b/common/java/com/android/common/content/SQLiteContentProvider.java @@ -49,6 +49,13 @@ public abstract class SQLiteContentProvider extends ContentProvider */ private static final int MAX_OPERATIONS_PER_YIELD_POINT = 500; + /** + * @return Number of operations that can be applied at once without a yield point. + */ + public int getMaxOperationsPerYield() { + return MAX_OPERATIONS_PER_YIELD_POINT; + } + @Override public boolean onCreate() { Context context = getContext(); @@ -204,7 +211,7 @@ public abstract class SQLiteContentProvider extends ContentProvider final int numOperations = operations.size(); final ContentProviderResult[] results = new ContentProviderResult[numOperations]; for (int i = 0; i < numOperations; i++) { - if (++opCount >= MAX_OPERATIONS_PER_YIELD_POINT) { + if (++opCount > getMaxOperationsPerYield()) { throw new OperationApplicationException( "Too many content provider operations between yield points. " + "The maximum number of operations per yield point is " @@ -232,14 +239,17 @@ public abstract class SQLiteContentProvider extends ContentProvider } } + @Override public void onBegin() { onBeginTransaction(); } + @Override public void onCommit() { beforeTransactionCommit(); } + @Override public void onRollback() { // not used } |