当前位置: 首页>>代码示例>>Java>>正文


Java Context.deleteDatabase方法代码示例

本文整理汇总了Java中android.content.Context.deleteDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java Context.deleteDatabase方法的具体用法?Java Context.deleteDatabase怎么用?Java Context.deleteDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Context的用法示例。


在下文中一共展示了Context.deleteDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDatabase

import android.content.Context; //导入方法依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EncryptedDbUtils.java

示例2: clearWebViewAllCache

import android.content.Context; //导入方法依赖的package包/类
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();
        }
    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:20,代码来源:AgentWebUtils.java

示例3: doMigration

import android.content.Context; //导入方法依赖的package包/类
static void doMigration(Context context, InboxManager inboxManager) {
    try {
        if (doesDatabaseExist(context, DBMigratorSQLiteHelper.DATABASE_NAME)) {
            DBMigratorSQLiteHelper dbHelper = new DBMigratorSQLiteHelper(context);
            if (dbHelper != null) {
                Cursor cursor = getTopEntryCursor(dbHelper.getWritableDatabase());
                while (cursor.moveToNext()) {
                    insertMessageFromEntry(inboxManager, cursor);
                }
                cursor.close();
                dbHelper.close();
                try {
                    context.deleteDatabase(DBMigratorSQLiteHelper.DATABASE_NAME);
                } catch (Exception e) {
                }
            }
        }
    } catch (Exception e2) {
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:21,代码来源:DBMigrator.java

示例4: deleteDatabases

import android.content.Context; //导入方法依赖的package包/类
private static void deleteDatabases(Context context) {
    String[] dbList = context.databaseList();
    if (dbList != null) {
        for (String file : dbList) {
            if (!context.deleteDatabase(file)) {
                Log.e(TAG, "Unable to delete database " + file + ".");
            }
        }
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:11,代码来源:ScraperReceiver.java

示例5: testCreateDb

import android.content.Context; //导入方法依赖的package包/类
/**
 * Tests that the database exists and the quotes table has the correct columns.
 */
@Test
public void testCreateDb() throws Exception {
    // build a HashSet of all of the table names we wish to look for
    // Note that there will be another table in the DB that stores the
    // Android metadata (db version information)
    final HashSet<String> tableNameHashSet = new HashSet<>();
    tableNameHashSet.add(FavoritesContract.FavoriteColumns.FAVORITE_MOVIES_TBL);
    tableNameHashSet.add(FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL);
    tableNameHashSet.add(FavoritesContract.FavoriteColumns.FAVORITE_PERSON_TBL);

    Context appContext = InstrumentationRegistry.getTargetContext();
    appContext.deleteDatabase(FavoritesDbHelper.DATABASE_NAME);
    SQLiteDatabase db = new FavoritesDbHelper(appContext).getWritableDatabase();
    assertEquals(true, db.isOpen());

    // have we created the tables we want?
    Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);

    assertTrue("Error: This means that the database has not been created correctly",
            c.moveToFirst());

    // verify that the tables have been created
    do {
        tableNameHashSet.remove(c.getString(0));
    } while( c.moveToNext() );

    // if this fails, it means that your database doesn't contain the tables
    assertTrue("Error: Your database was created without the tables", tableNameHashSet.isEmpty());

    // now, do our tables contain the correct columns?
    c = db.rawQuery("PRAGMA table_info(" + FavoritesContract.FavoriteColumns.FAVORITE_MOVIES_TBL + ")", null);
    assertTrue("Error: This means that we were unable to query the database for table information.",
            c.moveToFirst());

    // Build a HashSet of all of the column names we want to look for
    final HashSet<String> locationColumnHashSet = new HashSet<>();
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns._ID);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_MOVIE_ID);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_TITLE);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_PLOT);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_POSTER_PATH);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_YEAR);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_DURATION);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_VOTE_AVERAGE);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_VOTE_COUNT);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_BACKGROUND_PATH);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_ORIGINAL_LANGUAGE);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_STATUS);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_IMDB_ID);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_BUDGET);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_REVENUE);
    locationColumnHashSet.add(FavoritesContract.FavoriteColumns.COLUMN_HOMEPAGE);

    int columnNameIndex = c.getColumnIndex("name");
    do {
        String columnName = c.getString(columnNameIndex);
        locationColumnHashSet.remove(columnName);
    } while(c.moveToNext());

    c.close();
    // if this fails, it means that your database doesn't contain all of the required columns
    assertTrue("Error: The database doesn't contain all of the required columns",
            locationColumnHashSet.isEmpty());
    db.close();
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:69,代码来源:TestDB.java

示例6: SqlLiteHelper

import android.content.Context; //导入方法依赖的package包/类
/**
 * Constructor used to create database if database does not already exist.
 * Will delete existing Hexis database if PURGE_DATABASE is true
 *
 * @param context   Program context
 */
public SqlLiteHelper(Context context) {
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  // Delete Hexis database if PURGE_DATABASE is true
  if (PURGE_DATABASE) {

    // For testing purposes we need to delete the database so onCreate will be called
    context.deleteDatabase(DATABASE_NAME);

    // Delete actual database file from filesystem
    context.deleteFile(DATABASE_NAME);
  }
}
 
开发者ID:Austin-Ray,项目名称:Hexis,代码行数:19,代码来源:SqlLiteHelper.java

示例7: purgeDatabase

import android.content.Context; //导入方法依赖的package包/类
public void purgeDatabase(Context context) {
	context.deleteDatabase(DATABASE_NAME);
}
 
开发者ID:FrogSquare,项目名称:GodotSQL,代码行数:4,代码来源:KeyValDatabase.java

示例8: Remove

import android.content.Context; //导入方法依赖的package包/类
private void Remove(@NonNull Context context) {
    context.deleteDatabase(DATABASE_NAME);
}
 
开发者ID:GuepardoApps,项目名称:PasswordSafe-AndroidClient,代码行数:4,代码来源:DatabaseServerKey.java

示例9: removeDatabaseFor

import android.content.Context; //导入方法依赖的package包/类
public static void removeDatabaseFor(Context context, int aid) {
    dbHelperMap.remove(aid);
    context.deleteDatabase(DBHelper.getDatabaseFileName(aid));
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:DBHelper.java

示例10: cleanDatabaseByName

import android.content.Context; //导入方法依赖的package包/类
/**
 * * 按名字清除本应用数据库 * *
 */
public static void cleanDatabaseByName(Context context, String dbName) {
  context.deleteDatabase(dbName);
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:7,代码来源:DataCleanManager.java

示例11: deleteTheDatabase

import android.content.Context; //导入方法依赖的package包/类
private void deleteTheDatabase() {
    Context appContext = InstrumentationRegistry.getTargetContext();
    appContext.deleteDatabase(FavoritesDbHelper.DATABASE_NAME);
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:5,代码来源:TestDB.java

示例12: cleanDatabaseByName

import android.content.Context; //导入方法依赖的package包/类
/** * 按名字清除本应用数据库 * * @param context * @param dbName */
public static void cleanDatabaseByName(Context context, String dbName) {
    context.deleteDatabase(dbName);
}
 
开发者ID:androidstarjack,项目名称:ServiceDownLoadApp-master,代码行数:5,代码来源:DataCleanManager.java

示例13: deleteDatabase

import android.content.Context; //导入方法依赖的package包/类
public static void deleteDatabase(Context context) {
    context.deleteDatabase(DATABASE_NAME);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:4,代码来源:ScheduleDatabase.java

示例14: deleteDatabase

import android.content.Context; //导入方法依赖的package包/类
static void deleteDatabase(Context context) {
    context.deleteDatabase(DATABASE_NAME);
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:4,代码来源:MusicDatabaseHelper.java

示例15: cleanInternalDbByName

import android.content.Context; //导入方法依赖的package包/类
/**
 * 根据名称清除数据库
 * <p>/data/data/com.xxx.xxx/databases/dbName</p>
 *
 * @param dbName 数据库名称
 * @return {@code true}: 清除成功<br>{@code false}: 清除失败
 */
public static boolean cleanInternalDbByName(Context context, String dbName) {
    return context.deleteDatabase(dbName);
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:11,代码来源:FileUtil.java


注:本文中的android.content.Context.deleteDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。