DiskBasedCache implements Cache { private void initializeIfRootDirectoryDeleted() { if (!mRootDirectorySupplier.get().exists()) { VolleyLog.d("Re-initializing cache after external clearing."); mEntries.clear(); mTotalSize = 0; initialize(); } } DiskBasedCache(final File rootDirectory, int maxCacheSizeInBytes);  DiskBasedCache(FileSupplier rootDirectorySupplier, int maxCacheSizeInBytes);  DiskBasedCache(File rootDirectory);  DiskBasedCache(FileSupplier rootDirectorySupplier); @Override synchronized void clear(); @Override synchronized Entry get(String key); @Override synchronized void initialize(); @Override synchronized void invalidate(String key, boolean fullExpire); @Override synchronized void put(String key, Entry entry); @Override synchronized void remove(String key); File getFileForKey(String key);  }
@Test public void initializeIfRootDirectoryDeleted() { temporaryFolder.delete(); Cache.Entry entry = randomData(101); cache.put("key1", entry); assertThat(cache.get("key1"), is(nullValue())); cache.put("key2", entry); assertThatEntriesAreEqual(cache.get("key2"), entry); }