public DbOpenHelper(Context context) { super(context, DB_NAME, null, VERSION); // drop database if exists context.deleteDatabase(DbOpenHelper.DB_NAME); }
@Override public boolean deleteDatabase(String name) { return mBase.deleteDatabase(name); }
@VisibleForTesting /*package*/ void deleteApi14(Context context, File databaseFile) { context.deleteDatabase(databaseFile.getName()); } }
@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(); }
static void clearWebViewAllCache(Context context, WebView webView) { try { AgentWebConfig.removeAllCookies(null); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); context.deleteDatabase("webviewCache.db"); context.deleteDatabase("webview.db"); webView.clearCache(true); webView.clearHistory(); webView.clearFormData(); clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0); } catch (Exception ignore) { //ignore.printStackTrace(); if (AgentWebConfig.DEBUG) { ignore.printStackTrace(); } } }
/** 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); }
/** * Deletes the entire database. */ void deleteTheDatabase(){ try { /* Use reflection to get the database name from the db helper class */ Field f = mDbHelperClass.getDeclaredField("DATABASE_NAME"); f.setAccessible(true); mContext.deleteDatabase((String)f.get(null)); }catch (NoSuchFieldException ex){ fail("Make sure you have a member called DATABASE_NAME in the WaitlistDbHelper"); }catch (Exception ex){ fail(ex.getMessage()); } } }
/** * Deletes the entire database. */ void deleteTheDatabase(){ try { /* Use reflection to get the database name from the db helper class */ Field f = mDbHelperClass.getDeclaredField("DATABASE_NAME"); f.setAccessible(true); mContext.deleteDatabase((String)f.get(null)); }catch (NoSuchFieldException ex){ fail("Make sure you have a member called DATABASE_NAME in the WaitlistDbHelper"); }catch (Exception ex){ fail(ex.getMessage()); } } }
/** * Deletes the entire database. */ void deleteTheDatabase(){ try { /* Use reflection to get the database name from the db helper class */ Field f = mDbHelperClass.getDeclaredField("DATABASE_NAME"); f.setAccessible(true); mContext.deleteDatabase((String)f.get(null)); }catch (NoSuchFieldException ex){ fail("Make sure you have a member called DATABASE_NAME in the WaitlistDbHelper"); }catch (Exception ex){ fail(ex.getMessage()); } } }
/** * Deletes the entire database. */ void deleteTheDatabase(){ try { /* Use reflection to get the database name from the db helper class */ Field f = mDbHelperClass.getDeclaredField("DATABASE_NAME"); f.setAccessible(true); mContext.deleteDatabase((String)f.get(null)); }catch (NoSuchFieldException ex){ fail("Make sure you have a member called DATABASE_NAME in the WaitlistDbHelper"); }catch (Exception ex){ fail(ex.getMessage()); } } }
@Override protected void setUp() throws Exception { super.setUp(); getContext().deleteDatabase(TEST_DATABASE_NAME); }
@Override protected Database createDatabase() { getContext().deleteDatabase(ENCRYPTED_DB_FILE); return EncryptedDbUtils.createDatabase(getContext(), ENCRYPTED_DB_FILE, "password"); // You can do a sanity check by disabling encryption and see the test fail: // SQLiteDatabase sqLiteDatabase = getContext().openOrCreateDatabase(ENCRYPTED_DB_FILE, 0, null); // return new StandardDatabase(sqLiteDatabase); }
public static Database createDatabase(Context context, String dbName, String password) { if (!loadedLibs) { loadedLibs = true; SQLiteDatabase.loadLibs(context); } SQLiteDatabase sqLiteDatabase; if (dbName == null) { sqLiteDatabase = SQLiteDatabase.create(null, password); } else { File dbFile = context.getDatabasePath(dbName); dbFile.getParentFile().mkdir(); context.deleteDatabase(dbName); sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(dbFile, password, null); } return new EncryptedDatabase(sqLiteDatabase); }
@Override protected Database createDatabase() { int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; getContext().deleteDatabase(DB_NAME); SQLiteDatabase sqLiteDatabase = getContext().openOrCreateDatabase(DB_NAME, MODE_ENABLE_WRITE_AHEAD_LOGGING, null); return new StandardDatabase(sqLiteDatabase); }
@Test public void testDatabaseUpgrade5to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper5 openHelper = new JobOpenHelper5(context); createDatabase(openHelper, false); createJobs(openHelper, true); checkJob(); }
@Test public void testDatabaseUpgrade1to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper1 openHelper = new JobOpenHelper1(context); createDatabase(openHelper, false); createJobs(openHelper); checkJob(); }
@Test public void testDatabaseUpgrade3to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper3 openHelper = new JobOpenHelper3(context); createDatabase(openHelper, false); createJobs(openHelper, true); checkJob(); }
@Test public void testDatabaseUpgrade2to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper2 openHelper = new JobOpenHelper2(context); createDatabase(openHelper, false); createJobs(openHelper); checkJob(); }
@Test public void testDatabaseUpgrade4to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper4 openHelper = new JobOpenHelper4(context); createDatabase(openHelper, false); createJobs(openHelper, true); checkJob(); }
@Test public void testDatabaseUpgrade1to2to3to4to5to6() { Context context = RuntimeEnvironment.application; context.deleteDatabase(DATABASE_NAME); JobOpenHelper1 openHelper = new JobOpenHelper1(context); createDatabase(openHelper, false); createJobs(openHelper); createDatabase(new JobOpenHelper2(context), true); createDatabase(new JobOpenHelper3(context), true); createDatabase(new JobOpenHelper4(context), true); createDatabase(new JobOpenHelper5(context), true); checkJob(); }