Esempio n. 1
0
  public synchronized void pruneCache() {

    try {

      final HashSet<Long> currentFiles = new HashSet<Long>(128);

      final File externalCacheDir = context.getExternalCacheDir();
      final File internalCacheDir = context.getCacheDir();

      if (externalCacheDir != null) {
        getCacheFileList(externalCacheDir, currentFiles);
      }

      if (internalCacheDir != null) {
        getCacheFileList(internalCacheDir, currentFiles);
      }

      final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
      final HashMap<Integer, Long> maxAge = PrefsUtility.pref_cache_maxage(context, prefs);

      final LinkedList<Long> filesToDelete = dbManager.getFilesToPrune(currentFiles, maxAge, 72);
      for (final long id : filesToDelete) {
        fileDeletionQueue.enqueue(id);
      }

    } catch (Throwable t) {
      BugReportActivity.handleGlobalError(context, t);
    }
  }
Esempio n. 2
0
 public LinkedList<CacheEntry> getSessions(URI url, RedditAccount user) {
   return dbManager.select(url, user.username, null);
 }