Issue
I i found a way to access the Resources of the TestProject
Accessing resources in an android test project
but when i use the ActivityTestCase instead of AndroidTestcase i cannot access the database
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)
is there a way to have both?
Solution
Ok i solved my Problem:
i use now InstrumentationTestCase (i think ActivityTestCase would work either)
The Problem was that there are two contexts
Context mainProjectContext = getInstrumentation().getTargetContext();
Context testProjectContext = getInstrumentation().getContext();
now i can gat the resources from testProjectContext and let the database run with mainProjectContext
Answered By - wutzebaer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.