Example #1
0
  // 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");
  }