code: public boolean enableDiskCache(Context context, int storageDevice) {
          Context appContext = context.getApplicationContext();
  
          String rootDir = null;
          if (storageDevice == DISK_CACHE_SDCARD
                  && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
              // SD-card available
              rootDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/"
                      + appContext.getPackageName() + "/cache";
          } else {
              File internalCacheDir = appContext.getCacheDir();
              // apparently on some configurations this can come back as null
              if (internalCacheDir == null) {
                  return (isDiskCacheEnabled = false);
              }
              rootDir = internalCacheDir.getAbsolutePath();
          }
  
          setRootDir(rootDir);
  
          File outFile = new File(diskCacheDirectory);
          if (outFile.mkdirs()) {
              File nomedia = new File(diskCacheDirectory, ".nomedia");
              try {
                  nomedia.createNewFile();
              } catch (IOException e) {
                  Log.e(LOG_TAG, "Failed creating .nomedia file");
              }
          }
  
          isDiskCacheEnabled = outFile.exists();
  
          if (!isDiskCacheEnabled) {
              Log.w(LOG_TAG, "Failed creating disk cache directory " + diskCacheDirectory);
          } else {
              //Log.d(name, "enabled write through to " + diskCacheDirectory);
  
              // sanitize disk cache
              //Log.d(name, "sanitize DISK cache");
              sanitizeDiskCache();
          }
  
          return isDiskCacheEnabled;
      }
docs: Enable caching to the phone's internal storage or SD card.
  
  @param context
  the current context
  @param storageDevice
  where to store the cached files, either {@link #DISK_CACHE_INTERNAL} or
  {@link #DISK_CACHE_SDCARD})
  @return