summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/util/CacheManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/util/CacheManager.java')
-rw-r--r--src/com/android/gallery3d/util/CacheManager.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/com/android/gallery3d/util/CacheManager.java b/src/com/android/gallery3d/util/CacheManager.java
index ba466f79b..0e8f3e7d3 100644
--- a/src/com/android/gallery3d/util/CacheManager.java
+++ b/src/com/android/gallery3d/util/CacheManager.java
@@ -46,13 +46,15 @@ public class CacheManager {
BlobCache cache = sCacheMap.get(filename);
if (cache == null) {
File cacheDir = context.getExternalCacheDir();
- String path = cacheDir.getAbsolutePath() + "/" + filename;
- try {
- cache = new BlobCache(path, maxEntries, maxBytes, false,
- version);
- sCacheMap.put(filename, cache);
- } catch (IOException e) {
- Log.e(TAG, "Cannot instantiate cache!", e);
+ if (cacheDir != null) {
+ String path = cacheDir.getAbsolutePath() + "/" + filename;
+ try {
+ cache = new BlobCache(path, maxEntries, maxBytes, false,
+ version);
+ sCacheMap.put(filename, cache);
+ } catch (IOException e) {
+ Log.e(TAG, "Cannot instantiate cache!", e);
+ }
}
}
return cache;
@@ -73,10 +75,12 @@ public class CacheManager {
pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit();
File cacheDir = context.getExternalCacheDir();
- String prefix = cacheDir.getAbsolutePath() + "/";
+ if (cacheDir != null) {
+ String prefix = cacheDir.getAbsolutePath() + "/";
- BlobCache.deleteFiles(prefix + "imgcache");
- BlobCache.deleteFiles(prefix + "rev_geocoding");
- BlobCache.deleteFiles(prefix + "bookmark");
+ BlobCache.deleteFiles(prefix + "imgcache");
+ BlobCache.deleteFiles(prefix + "rev_geocoding");
+ BlobCache.deleteFiles(prefix + "bookmark");
+ }
}
}