【发布时间】:2014-11-07 09:09:29
【问题描述】:
我找到了访问 TestProject 资源的方法
Accessing resources in an android test project
但是当我使用 ActivityTestCase 而不是 AndroidTestcase 时,我无法访问数据库
java.lang.NullPointerException
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidConnectionSource.java:66)
at com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection(AndroidConnectionSource.java:54)
at com.j256.ormlite.dao.BaseDaoImpl.idExists(BaseDaoImpl.java:805)
at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:335)
有没有办法两者兼得?
【问题讨论】:
标签: android sqlite android-resources