android.content.Context.deleteDatabase()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中android.content.Context.deleteDatabase()方法的一些代码示例,展示了Context.deleteDatabase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.deleteDatabase()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:deleteDatabase

Context.deleteDatabase介绍

暂无

代码示例

代码示例来源:origin: xfumihiro/ViewInspector

public DbOpenHelper(Context context) {
 super(context, DB_NAME, null, VERSION);
 // drop database if exists
 context.deleteDatabase(DbOpenHelper.DB_NAME);
}

代码示例来源:origin: oasisfeng/condom

@Override public boolean deleteDatabase(String name) {
  return mBase.deleteDatabase(name);
}

代码示例来源:origin: evernote/android-job

@VisibleForTesting
  /*package*/ void deleteApi14(Context context, File databaseFile) {
    context.deleteDatabase(databaseFile.getName());
  }
}

代码示例来源:origin: greenrobot/greenDAO

@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();
}

代码示例来源:origin: Justson/AgentWeb

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();
    }
  }
}

代码示例来源:origin: greenrobot/greenDAO

/** 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);
}

代码示例来源:origin: udacity/ud851-Exercises

/**
   * 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());
    }

  }
}

代码示例来源:origin: udacity/ud851-Exercises

/**
   * 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());
    }

  }
}

代码示例来源:origin: udacity/ud851-Exercises

/**
   * 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());
    }

  }
}

代码示例来源:origin: udacity/ud851-Exercises

/**
   * 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());
    }

  }
}

代码示例来源:origin: grandcentrix/tray

@Override
protected void setUp() throws Exception {
  super.setUp();
  getContext().deleteDatabase(TEST_DATABASE_NAME);
}

代码示例来源:origin: greenrobot/greenDAO

@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);
}

代码示例来源:origin: greenrobot/greenDAO

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);
}

代码示例来源:origin: greenrobot/greenDAO

@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);
}

代码示例来源:origin: evernote/android-job

@Test
public void testDatabaseUpgrade5to6() {
  Context context = RuntimeEnvironment.application;
  context.deleteDatabase(DATABASE_NAME);
  JobOpenHelper5 openHelper = new JobOpenHelper5(context);
  createDatabase(openHelper, false);
  createJobs(openHelper, true);
  checkJob();
}

代码示例来源:origin: evernote/android-job

@Test
public void testDatabaseUpgrade1to6() {
  Context context = RuntimeEnvironment.application;
  context.deleteDatabase(DATABASE_NAME);
  JobOpenHelper1 openHelper = new JobOpenHelper1(context);
  createDatabase(openHelper, false);
  createJobs(openHelper);
  checkJob();
}

代码示例来源:origin: evernote/android-job

@Test
public void testDatabaseUpgrade3to6() {
  Context context = RuntimeEnvironment.application;
  context.deleteDatabase(DATABASE_NAME);
  JobOpenHelper3 openHelper = new JobOpenHelper3(context);
  createDatabase(openHelper, false);
  createJobs(openHelper, true);
  checkJob();
}

代码示例来源:origin: evernote/android-job

@Test
public void testDatabaseUpgrade2to6() {
  Context context = RuntimeEnvironment.application;
  context.deleteDatabase(DATABASE_NAME);
  JobOpenHelper2 openHelper = new JobOpenHelper2(context);
  createDatabase(openHelper, false);
  createJobs(openHelper);
  checkJob();
}

代码示例来源:origin: evernote/android-job

@Test
public void testDatabaseUpgrade4to6() {
  Context context = RuntimeEnvironment.application;
  context.deleteDatabase(DATABASE_NAME);
  JobOpenHelper4 openHelper = new JobOpenHelper4(context);
  createDatabase(openHelper, false);
  createJobs(openHelper, true);
  checkJob();
}

代码示例来源:origin: evernote/android-job

@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();
}

相关文章

Context类方法