List of usage examples for android.content Context deleteDatabase
public abstract boolean deleteDatabase(String name);
From source file:com.just.agentweb.AgentWebUtils.java
static void clearWebViewAllCache(Context context, WebView webView) { try {//from w w w. j a v a2 s . com 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(); } } }
From source file:com.secupwn.aimsicd.utils.Helpers.java
/** * Description: Deletes the entire database by removing internal SQLite DB file * /*from ww w .j a v a 2s . c o m*/ * * Dependencies: Used in AIMSICD.java * * Notes: See Android developer info: http://tinyurl.com/psz8vmt * * WARNING! * This deletes the entire database, thus any subsequent DB access will FC app. * Therefore we need to either restart app or run AIMSICDDbAdapter, to rebuild DB. * See: #581 * * In addition, since SQLite is kept in memory during lifetime of App, and * is using Journaling, we have to restart app in order to clear old data * already in memory. * * @param pContext Context of Activity */ public static void askAndDeleteDb(final Context pContext) { AlertDialog lAlertDialog = new AlertDialog.Builder(pContext) .setNegativeButton(R.string.open_cell_id_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(R.string.open_cell_id_button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Probably put in try/catch in case file removal fails... pContext.stopService(new Intent(pContext, AimsicdService.class)); pContext.deleteDatabase("aimsicd.db"); new RealmHelper(pContext); pContext.startService(new Intent(pContext, AimsicdService.class)); msgLong(pContext, pContext.getString(R.string.delete_database_msg_success)); } }).setMessage(pContext.getString(R.string.clear_database_question)) .setTitle(R.string.clear_database).setCancelable(false) .setIcon(R.drawable.ic_action_delete_database).create(); lAlertDialog.show(); }
From source file:com.liferay.alerts.database.DatabaseHelper.java
public void deleteDatabase(Context context) { AlertDAO.destroy();/*from w w w.j a va 2s . c om*/ UserDAO.destroy(); try { _instance.close(); } catch (RuntimeException re) { } context.deleteDatabase(_DATABASE_NAME); }
From source file:com.android.server.MaybeDatabaseHelper.java
private void initDatabase(Context context) { try {/*from w w w . j a v a2 s . com*/ sDatabase = context.openOrCreateDatabase(DBNAME, 0, null); } catch (SQLiteException e) { Log.e(DBTAG, "Exception while opening database. Retrying."); e.printStackTrace(); if (context.deleteDatabase(DBNAME)) { sDatabase = context.openOrCreateDatabase(DBNAME, 0, null); } } if (sDatabase == null) { //Use for any damage control because something went wrong horribly //if sDatabase is null at this point Log.d(DBTAG, "sDatabase is null"); } //sDatabase.execSQL("DROP TABLE IF EXISTS apptable"); sDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + APP_TABLE_NAME + " (" + ID_COL + " INTEGER PRIMARY_KEY, " + PACKAGE_COL + " TEXT, " + GCM_COL + " TEXT, " + URL_COL + " TEXT, " + HASH_COL + " TEXT, " + DATA_COL + " TEXT, " + STALE_COL + " BOOLEAN, " + PUSH_COL + " BOOLEAN " + ");"); }
From source file:org.wso2.emm.agent.utils.CommonUtils.java
/** * Clear application data./*from w w w. j a v a2 s. c om*/ * @param context - Application context. */ public static void clearAppData(Context context) throws AndroidAgentException { try { revokePolicy(context); } catch (SecurityException e) { throw new AndroidAgentException("Error occurred while revoking policy", e); } finally { Resources resources = context.getResources(); SharedPreferences mainPref = context.getSharedPreferences(Constants.AGENT_PACKAGE, Context.MODE_PRIVATE); Editor editor = mainPref.edit(); editor.putBoolean(Constants.PreferenceFlag.IS_AGREED, false); editor.putString(Constants.PreferenceFlag.REG_ID, null); editor.putBoolean(Constants.PreferenceFlag.REGISTERED, false); editor.putString(Constants.PreferenceFlag.IP, null); editor.putString(Constants.PreferenceFlag.NOTIFIER_TYPE, null); editor.putString(context.getResources().getString(R.string.shared_pref_sender_id), resources.getString(R.string.shared_pref_default_string)); editor.putString(context.getResources().getString(R.string.shared_pref_eula), resources.getString(R.string.shared_pref_default_string)); editor.putBoolean(Constants.PreferenceFlag.DEVICE_ACTIVE, false); editor.commit(); Preference.clearPreferences(context); clearClientCredentials(context); context.deleteDatabase(Constants.EMM_DB); } }
From source file:com.colorchen.qbase.utils.FileUtil.java
/** * ????/*from w w w . j a v a2s . com*/ * <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); }
From source file:com.nuvolect.securesuite.data.SqlCipher.java
public static synchronized void deleteDatabases(Context ctx) { ctx.deleteDatabase(ACCOUNT_DB_NAME); ctx.deleteDatabase(DETAIL_DB_NAME);/*w ww. ja va 2 s .co m*/ }