vendredi 6 février 2015

Testing sqlitedatadase in android

I'm new to JUnit testing. I have an Android project with a SQliteOpenHelper class that open my sqlite database in my asset folder.


Now, I want to test some classes that use this database. I copied the database in the asset folder of the testing project and I create and open the database in the setUp(). The creation is a copying to the database folder from the asset folder (this work on my project) because is an external database.


But the test give me an "could not open database" exception. I'm doing something wrong?



protected void setUp() throws Exception {

super.setUp();

Context context = getInstrumentation().getContext();

DataHelper DataHelper = new DataHelper(context);
try {
DataHelper.createDataBase();
} catch (IOException e) {
e.printStackTrace();
}
SQliteDatabase db = DataHelper.getReadableDatabase();

}

Aucun commentaire:

Enregistrer un commentaire