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工程中访问受限。

你可能感兴趣的:(database)