// Removes the old files if the data is wiped. private static void removeOldFilesIfNecessary(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); int n = 0; try { n = pref.getInt(KEY_CACHE_UP_TO_DATE, 0); } catch (Throwable t) { // ignore. } if (n != 0) return; pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit(); /// M: [BEHAVIOR.MODIFY] @{ /*File cacheDir = context.getExternalCacheDir();*/ File cacheDir = FeatureHelper.getExternalCacheDir(context); if (cacheDir == null) { Log.e(TAG, "<removeOldFilesIfNecessary> failed to get cache dir"); return; } /// @} String prefix = cacheDir.getAbsolutePath() + "/"; BlobCache.deleteFiles(prefix + "imgcache"); BlobCache.deleteFiles(prefix + "rev_geocoding"); BlobCache.deleteFiles(prefix + "bookmark"); }
// Removes the old files if the data is wiped. private static void removeOldFilesIfNecessary(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); int n = 0; try { n = pref.getInt(KEY_CACHE_UP_TO_DATE, 0); } catch (Throwable t) { // ignore. } if (n != 0) return; pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit(); File cacheDir = context.getExternalCacheDir(); String prefix = cacheDir.getAbsolutePath() + "/"; BlobCache.deleteFiles(prefix + "imgcache"); BlobCache.deleteFiles(prefix + "rev_geocoding"); BlobCache.deleteFiles(prefix + "bookmark"); }
public static void storageStateChanged(boolean mounted) { synchronized (sCacheMap) { if (mounted) { // this is lazy initialization: we do NOT re-open all cache files until they are needed // again sNoStorage = false; } else { // clear cache map and disable cache access sNoStorage = true; for (BlobCache cache : sCacheMap.values()) { // close all entry's "value", which is a BlobCache Log.d(TAG, " => closing " + cache); cache.close(); Log.d(TAG, " <= closing " + cache); } sCacheMap.clear(); } } }