本文整理汇总了Java中android.database.sqlite.SQLiteDatabaseLockedException类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabaseLockedException类的具体用法?Java SQLiteDatabaseLockedException怎么用?Java SQLiteDatabaseLockedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteDatabaseLockedException类属于android.database.sqlite包,在下文中一共展示了SQLiteDatabaseLockedException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertCallback
import android.database.sqlite.SQLiteDatabaseLockedException; //导入依赖的package包/类
@Override
protected void insertCallback(Team team) {
ContentValues cv = new ContentValues();
mDb.beginTransaction();
try {
cv.put(Database.SearchTeam.KEY, team.getKey());
cv.put(Database.SearchTeam.TITLES, Utilities.getAsciiApproximationOfUnicode(team.getSearchTitles()));
cv.put(Database.SearchTeam.NUMBER, team.getTeamNumber());
mDb.insert(Database.TABLE_SEARCH_TEAMS, null, cv);
mDb.setTransactionSuccessful();
} catch (SQLiteException ex) {
if (ex instanceof SQLiteDatabaseLockedException) {
TbaLogger.d("Databse locked: " + ex.getMessage());
} else {
TbaLogger.w("Error in team insert callback", ex);
}
} finally {
mDb.endTransaction();
}
}
示例2: setJournalMode
import android.database.sqlite.SQLiteDatabaseLockedException; //导入依赖的package包/类
private void setJournalMode(String newValue) {
String value = executeForString("PRAGMA journal_mode", null, null);
if (!value.equalsIgnoreCase(newValue)) {
try {
String result = executeForString("PRAGMA journal_mode=" + newValue, null, null);
if (result.equalsIgnoreCase(newValue)) {
return;
}
// PRAGMA journal_mode silently fails and returns the original journal
// mode in some cases if the journal mode could not be changed.
} catch (SQLiteException ex) {
// This error (SQLITE_BUSY) occurs if one connection has the database
// open in WAL mode and another tries to change it to non-WAL.
if (!(ex instanceof SQLiteDatabaseLockedException)) {
throw ex;
}
}
// Because we always disable WAL mode when a database is first opened
// (even if we intend to re-enable it), we can encounter problems if
// there is another open connection to the database somewhere.
// This can happen for a variety of reasons such as an application opening
// the same database in multiple processes at the same time or if there is a
// crashing content provider service that the ActivityManager has
// removed from its registry but whose process hasn't quite died yet
// by the time it is restarted in a new process.
//
// If we don't change the journal mode, nothing really bad happens.
// In the worst case, an application that enables WAL might not actually
// get it, although it can still use connection pooling.
Log.w(TAG, "Could not change the database journal mode of '"
+ mConfiguration.label + "' from '" + value + "' to '" + newValue
+ "' because the database is locked. This usually means that "
+ "there are other open connections to the database which prevents "
+ "the database from enabling or disabling write-ahead logging mode. "
+ "Proceeding without changing the journal mode.");
}
}
示例3: getDnsCache
import android.database.sqlite.SQLiteDatabaseLockedException; //导入依赖的package包/类
/**
* 获取url缓存
* @param url
* @return
*/
@Override
public DomainModel getDnsCache(String sp, String url){
DomainModel model = data.get(url) ;
if( model == null ){
//缓存中没有从数据库中查找
ArrayList<DomainModel> list = null;
try {
list = (ArrayList<DomainModel>) db.QueryDomainInfo(url, sp);
} catch(SQLiteDatabaseLockedException e){
e.printStackTrace();
}
if( list != null && list.size() != 0){
model = list.get( list.size() - 1 ) ;
}
//查询到数据 添加到缓存中
if( model != null )addMemoryCache(url, model) ;
}
if( model != null){
//检测是否过期
if( isExpire(model, ip_overdue_delay) ){
model = null ;
}
}
return model ;
}
示例4: onStartCommand
import android.database.sqlite.SQLiteDatabaseLockedException; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Logger.d("DataUploadService: onStartCommand");
(new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
String permissionResponse = getPermissionResponse();
if (!hasWritePermission(permissionResponse)) {
stopSelf();
}
Cursor cursor = null;
try {
if (db == null) {
return null;
}
cursor = db.query(TABLE_GROUPS,
new String[] { COLUMN_TABLE_ID, COLUMN_MSG },
COLUMN_UPLOADED + " is null AND " + COLUMN_READY_FOR_UPLOAD + " == ?",
new String[] { "1" }, null, null, null);
while (cursor.moveToNext()) {
int groupIdIndex = cursor.getColumnIndex(COLUMN_TABLE_ID);
int routeDescription = cursor.getColumnIndex(COLUMN_MSG);
generateGpxXmlFor(cursor.getString(groupIdIndex),
cursor.getString(routeDescription));
}
} catch (SQLiteDatabaseLockedException exception) {
Logger.d("DataUpload: database is locked lets try again later");
} finally {
if (cursor != null) {
cursor.close();
}
}
return null;
}
}).execute();
return Service.START_NOT_STICKY;
}