• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLiteDatabaseLockedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
    }
}
 
开发者ID:the-blue-alliance,项目名称:the-blue-alliance-android,代码行数:21,代码来源:TeamsTable.java


示例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.");
    }
}
 
开发者ID:requery,项目名称:sqlite-android,代码行数:39,代码来源:SQLiteConnection.java


示例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 ; 
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:38,代码来源:DnsCacheManager.java


示例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;
}
 
开发者ID:mapzen,项目名称:open,代码行数:38,代码来源:DataUploadService.java



注:本文中的android.database.sqlite.SQLiteDatabaseLockedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleStringFilter类代码示例发布时间:2022-05-21
下一篇:
Java PartialResultException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap