Ensure that the cache folder exists
Make sure that the cache folder exists when using DiskBasedCache.
Change-Id: I60e2c2b0b88c9a3a178e72dda05ab5f7290e33f0
diff --git a/src/com/android/volley/toolbox/DiskBasedCache.java b/src/com/android/volley/toolbox/DiskBasedCache.java
index d421480..c04ba87 100644
--- a/src/com/android/volley/toolbox/DiskBasedCache.java
+++ b/src/com/android/volley/toolbox/DiskBasedCache.java
@@ -72,6 +72,12 @@
public DiskBasedCache(File rootDirectory, int maxCacheSizeInBytes) {
mRootDirectory = rootDirectory;
mMaxCacheSizeInBytes = maxCacheSizeInBytes;
+
+ if (!mRootDirectory.exists()) {
+ if (!mRootDirectory.mkdirs()) {
+ VolleyLog.e("Unable to create cache dir %s", mRootDirectory.getAbsolutePath());
+ }
+ }
}
/**