當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。