public void initDiskCache(){
synchronized (mDiskCacheLock) {
    if (mDiskLruCache == null || mDiskLruCache.isClosed()) {
      File diskCacheDir=mCacheParams.diskCacheDir;
      if (mCacheParams.diskCacheEnabled && diskCacheDir != null) {
        if (!diskCacheDir.exists()) {
          diskCacheDir.mkdirs();
        }
        if (Utils.getUsableSpace(diskCacheDir) > mCacheParams.diskCacheSize) {
          try {
            mDiskLruCache=DiskLruCache.open(diskCacheDir,APP_VERSION,VALUE_COUNT,mCacheParams.diskCacheSize);
            if (BuildConfig.DEBUG) {
              VolleyLog.d("Disk cache initialized");
            }
          }
 catch (          final IOException e) {
            mCacheParams.diskCacheDir=null;
            VolleyLog.e("initDiskCache - " + e);
          }
        }
      }
    }
    mDiskCacheStarting=false;
    mDiskCacheLock.notifyAll();
  }
}

public void initDiskCache ( ) { synchronized ( mDiskCacheLock ) { if ( mDiskLruCache == null || mDiskLruCache . isClosed ( ) ) { File diskCacheDir = mCacheParams . diskCacheDir ; if ( mCacheParams . diskCacheEnabled && diskCacheDir != null ) { if ( ! diskCacheDir . exists ( ) ) { diskCacheDir . mkdirs ( ) ; } if ( Utils . getUsableSpace ( diskCacheDir ) > mCacheParams . diskCacheSize ) { try { mDiskLruCache = DiskLruCache . open ( diskCacheDir , APP_VERSION , VALUE_COUNT , mCacheParams . diskCacheSize ) ; if ( BuildConfig . DEBUG ) { VolleyLog . d ( "Disk cache initialized" ) ; } } catch ( final IOException e ) { mCacheParams . diskCacheDir = null ; VolleyLog . e ( "initDiskCache - " + e ) ; } } } } mDiskCacheStarting = false ; mDiskCacheLock . notifyAll ( ) ; } }
initializes the disk cache . note that this includes disk access so this should not be executed on the main / ui thread . by default an imagecache does not initialize the disk cache when it is created , instead you should call initdiskcache ( ) to initialize it on a background thread .
