private static File createTempFile(Context context,@Nullable String mimeType) throws IOException {
  File externalCacheDir=context.getExternalCacheDir();
  File internalCacheDir=context.getCacheDir();
  File cacheDir;
  if (externalCacheDir == null && internalCacheDir == null) {
    throw new IOException("No cache directory available");
  }
  if (externalCacheDir == null) {
    cacheDir=internalCacheDir;
  }
 else   if (internalCacheDir == null) {
    cacheDir=externalCacheDir;
  }
 else {
    cacheDir=externalCacheDir.getFreeSpace() > internalCacheDir.getFreeSpace() ? externalCacheDir : internalCacheDir;
  }
  return File.createTempFile(TEMP_FILE_PREFIX,getFileExtensionForType(mimeType),cacheDir);
}

private static File createTempFile ( Context context , @ Nullable String mimeType ) throws IOException { File externalCacheDir = context . getExternalCacheDir ( ) ; File internalCacheDir = context . getCacheDir ( ) ; File cacheDir ; if ( externalCacheDir == null && internalCacheDir == null ) { throw new IOException ( "No cache directory available" ) ; } if ( externalCacheDir == null ) { cacheDir = internalCacheDir ; } else if ( internalCacheDir == null ) { cacheDir = externalCacheDir ; } else { cacheDir = externalCacheDir . getFreeSpace ( ) > internalCacheDir . getFreeSpace ( ) ? externalCacheDir : internalCacheDir ; } return File . createTempFile ( TEMP_FILE_PREFIX , getFileExtensionForType ( mimeType ) , cacheDir ) ; }
create a temporary file in the cache directory on either internal or external storage , whichever is available and has more free space .
