本文整理汇总了Java中android.database.sqlite.SQLiteDatabase.yieldIfContendedSafely方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabase.yieldIfContendedSafely方法的具体用法?Java SQLiteDatabase.yieldIfContendedSafely怎么用?Java SQLiteDatabase.yieldIfContendedSafely使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.sqlite.SQLiteDatabase
的用法示例。
在下文中一共展示了SQLiteDatabase.yieldIfContendedSafely方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bulkInsert
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public int bulkInsert(Uri uri, ContentValues[] values) {
if (DBG) Log.d(TAG, "bulkInsert " + uri);
int match = URI_MATCHER.match(uri);
// let ScraperProvider handle that
if (ScraperProvider.handles(match))
return mScraperProvider.bulkInsert(uri, values);
if (match != -1) {
int result = 0;
mVobHandler.onBeginTransaction();
SQLiteDatabase db = mDbHolder.get();
db.beginTransactionNonExclusive();
try {
int numValues = values.length;
int yield = 100;
for (int i = 0; i < numValues; i++) {
insert(uri, values[i]);
if (yield-- < 0) {
yield = 100;
db.yieldIfContendedSafely();
}
}
result = numValues;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
mVobHandler.onEndTransaction();
}
if (result > 0)
mCr.notifyChange(VideoStore.ALL_CONTENT_URI, null);
return result;
}
return 0;
}
示例2: applyBatch
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
throws OperationApplicationException {
if (DBG) Log.d(TAG, "applyBatch");
ContentProviderResult[] result = null;
SQLiteDatabase db = mDbHolder.get();
mVobHandler.onBeginTransaction();
db.beginTransactionNonExclusive();
try {
final int numOperations = operations.size();
final ContentProviderResult[] results = new ContentProviderResult[numOperations];
int yield = 100;
for (int i = 0; i < numOperations; i++) {
results[i] = operations.get(i).apply(this, results, i);
if (yield-- < 0) {
yield = 100;
db.yieldIfContendedSafely();
}
}
result = results;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
mVobHandler.onEndTransaction();
}
if (result != null) {
mCr.notifyChange(VideoStore.ALL_CONTENT_URI, null);
mCr.notifyChange(ScraperStore.ALL_CONTENT_URI, null);
}
return result;
}