List of usage examples for android.content ContentProviderOperation isYieldAllowed
public boolean isYieldAllowed()
From source file:com.manning.androidhacks.hack043.provider.SQLiteContentProvider.java
@Override public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) throws OperationApplicationException { mDb = mOpenHelper.getWritableDatabase(); mDb.beginTransactionWithListener(this); try {/*from w w w . j a v a2s . c om*/ mApplyingBatch.set(true); final int numOperations = operations.size(); final ContentProviderResult[] results = new ContentProviderResult[numOperations]; for (int i = 0; i < numOperations; i++) { final ContentProviderOperation operation = operations.get(i); if (i > 0 && operation.isYieldAllowed()) { mDb.yieldIfContendedSafely(SLEEP_AFTER_YIELD_DELAY); } results[i] = operation.apply(this, results, i); } mDb.setTransactionSuccessful(); return results; } finally { mApplyingBatch.set(false); mDb.endTransaction(); onEndTransaction(); } }