• Android 数据库 OrmLite Failed to open database


    04-01 16:49:32.720: E/SQLiteLog(1894): (14) cannot open file at line 30204 of [00bb9c9ce4]
    04-01 16:49:32.720: E/SQLiteLog(1894): (14) os_unix.c:30204: (2) open(/data/data/com.xxx.test/databases/weaver_data) -
    04-01 16:49:32.730: E/SQLiteDatabase(1894): Failed to open database '/data/data/com.xxx.test/databases/weaver_data'.
    04-01 16:49:32.730: E/SQLiteDatabase(1894): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:212)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:464)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:186)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:698)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:983)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidConnectionSource.java:66)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection(AndroidConnectionSource.java:54)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.j256.ormlite.dao.BaseDaoImpl.idExists(BaseDaoImpl.java:805)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:335)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.xxx.b.data.DataService.createOrUpdate(DataService.java:175)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.xxx.b.data.model.AbstractDataItem.update(AbstractDataItem.java:21)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.xxx.b.data.DataService.handleDataEvent(DataService.java:128)
    04-01 16:49:32.730: E/SQLiteDatabase(1894): at com.xxx.b.data.DataService.run(DataService.java:89)
    04-01 16:49:32.730: W/System.err(1894): java.sql.SQLException: Getting a writable database from helper DatabaseHelper@41a2b838 failed
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidConnectionSource.java:68)
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection(AndroidConnectionSource.java:54)
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.dao.BaseDaoImpl.idExists(BaseDaoImpl.java:805)
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:335)
    04-01 16:49:32.730: W/System.err(1894): at com.xxx.b.data.DataService.createOrUpdate(DataService.java:175)
    04-01 16:49:32.730: W/System.err(1894): at com.xxx.b.data.model.AbstractDataItem.update(AbstractDataItem.java:21)
    04-01 16:49:32.730: W/System.err(1894): at com.xxx.b.data.DataService.handleDataEvent(DataService.java:128)
    04-01 16:49:32.730: W/System.err(1894): at com.xxx.b.data.DataService.run(DataService.java:89)
    04-01 16:49:32.730: W/System.err(1894): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:212)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:464)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:186)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:698)
    04-01 16:49:32.730: W/System.err(1894): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:983)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
    04-01 16:49:32.730: W/System.err(1894): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
    04-01 16:49:32.730: W/System.err(1894): at com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidConnectionSource.java:66)
    04-01 16:49:32.730: W/System.err(1894): ... 7 more

    开始以为是路径权限有问题。

    后来查出是:使用Android JUnit Test方式测试A工程。而A工程和Test工程 是两个独立的工程。

    造成A工程建立了数据库,在Test工程中访问受限。

  • 相关阅读:
    2019 icpc南昌全国邀请赛-网络选拔赛J题 树链剖分+离线询问
    Android小项目之十二 设置中心的界面
    【Mood-5】14条建议,使你的IT职业生涯更上一层楼
    【Android 界面效果15】Android UI 之一步步教你自定义控件(自定义属性、合理设计onMeasure、合理设计onDraw等)
    单线程模型中Message、Handler、Message Queue、Looper之间的关系
    140个google面试题
    Android小项目之十一 应用程序的主界面
    Android小项目之十 应用程序更新的签名问题
    Android小项目之九 两种上下文的区别
    Android小项目之八 界面细节
  • 原文地址:https://www.cnblogs.com/maxiaodoubao/p/4384724.html
Copyright © 2020-2023  润新知