/** Returns a prepared application with the onCreate method already called. */ public <T extends Application> T createApplication(Class<T> appClass) { assertNull("Application already created", application); T app; try { app = (T) Instrumentation.newApplication(appClass, getContext()); } catch (Exception e) { throw new RuntimeException("Could not create application " + appClass, e); } app.onCreate(); application = app; return app; }
/** May be overriden by sub classes to set up a different db. */ protected Database createDatabase() { SQLiteDatabase sqLiteDatabase; if (inMemory) { sqLiteDatabase = SQLiteDatabase.create(null); } else { getContext().deleteDatabase(DB_NAME); sqLiteDatabase = getContext().openOrCreateDatabase(DB_NAME, 0, null); } return new StandardDatabase(sqLiteDatabase); }
@Override /** Closes the db, and terminates an application, if one was created before. */ protected void tearDown() throws Exception { if (application != null) { terminateApplication(); } db.close(); if (!inMemory) { getContext().deleteDatabase(DB_NAME); } super.tearDown(); }
/** Returns a prepared application with the onCreate method already called. */ public <T extends Application> T createApplication(Class<T> appClass) { assertNull("Application already created", application); T app; try { app = (T) Instrumentation.newApplication(appClass, getContext()); } catch (Exception e) { throw new RuntimeException("Could not create application " + appClass, e); } app.onCreate(); application = app; return app; }
/** May be overriden by sub classes to set up a different db. */ protected Database createDatabase() { SQLiteDatabase sqLiteDatabase; if (inMemory) { sqLiteDatabase = SQLiteDatabase.create(null); } else { getContext().deleteDatabase(DB_NAME); sqLiteDatabase = getContext().openOrCreateDatabase(DB_NAME, 0, null); } return new StandardDatabase(sqLiteDatabase); }
@Override /** Closes the db, and terminates an application, if one was created before. */ protected void tearDown() throws Exception { if (application != null) { terminateApplication(); } db.close(); if (!inMemory) { getContext().deleteDatabase(DB_NAME); } super.tearDown(); }