Get the external app cache directory.

@param context The context to use
@return The external cache dir
485078
@TargetApi(8)
    public static File getExternalCacheDir(Context context) {
        // Do we have a built-in external cache dir method.
        if (Android.isAPI(8)) {
            File cacheDir = context.getExternalCacheDir();
            if (cacheDir != null) {
                return cacheDir;
            }
        }

        // Before Froyo we need to construct the external cache dir ourselves
        final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
        return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
    }
1151013
protected static ArrayCache getArrayCache() {
        ArrayCache cache = (ArrayCache) AppContext.getAppContext().get(ArrayCache.class);

        if (cache == null) {
            cache = new ArrayCache();
            AppContext.getAppContext().put(ArrayCache.class, cache);
        }

        return cache;
    }
99980
def get_cache_dir(shell_ctx):
    
    azure_folder = shell_ctx.config.get_config_dir()
    cache_path = os.path.join(azure_folder, 'cache')
    if not os.path.exists(azure_folder):
        os.makedirs(azure_folder)
    if not os.path.exists(cache_path):
        os.makedirs(cache_path)
    return cache_path
1365332
public static String getCacheDir(Context ctx) {
        return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || (!Environment.isExternalStorageRemovable() && ctx.getExternalCacheDir() != null) ?
                ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath();
    }
213162
@TargetApi(Build.VERSION_CODES.FROYO)
    public static File getExternalFilesDirForMovies(Context context) {
        return context.getExternalFilesDir(Environment.DIRECTORY_MOVIES);
    }
274115
private static File computeCacheDirectory() {
        String path = System.getenv("COURSIER_CACHE");

        if (path == null)
            path = System.getProperty("coursier.cache");

        File baseXdgDir = new File(coursierDirectories.cacheDir);
        File xdgDir = new File(baseXdgDir, "v1");
        String xdgPath = xdgDir.getAbsolutePath();

        if (path == null) {
            if (baseXdgDir.isDirectory())
              path = xdgPath;
        }

        if (path == null) {
            File coursierDotFile = new File(System.getProperty("user.home") + "/.coursier");
            if (coursierDotFile.isDirectory())
                path = System.getProperty("user.home") + "/.coursier/cache/v1/";
        }

        if (path == null) {
            path = xdgPath;
            xdgDir.mkdirs();
        }

        return new File(path).getAbsoluteFile();
    }
487848
private function getData($context)
    {
        if (!array_key_exists($context, $this->storage)) {
            $this->storage[$context] = new FilesystemCache($this->directory . '/' . $context, self::EXTENSION);
        }

        return $this->storage[$context];
    }
194151
public static List<String> getDexFilePaths(Context context) {
        ApplicationInfo appInfo = context.getApplicationInfo();
        File sourceApk = new File(appInfo.sourceDir);

        List<String> sourcePaths = new ArrayList<>();
        sourcePaths.add(appInfo.sourceDir);

        if (!isVMMultidexCapable()) {
            String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
            int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
            File dexDir = new File(appInfo.dataDir, CODE_CACHE_SECONDARY_DIRECTORY);

            for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
                String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
                File extractedFile = new File(dexDir, fileName);
                if (extractedFile.isFile()) {
                    sourcePaths.add(extractedFile.getAbsolutePath());
                }
            }
        }

        if (AndServer.isDebug()) {
            sourcePaths.addAll(loadInstantRunDexFile(appInfo));
        }
        return sourcePaths;
    }
453909
@Nullable
  private File getCachedFile(String url) throws FileNotFoundException {
    File jsonFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.JSON, false));
    if (jsonFile.exists()) {
      return jsonFile;
    }
    File zipFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.ZIP, false));
    if (zipFile.exists()) {
      return zipFile;
    }
    return null;
  }
814732
def user_cache_dir(self):
        """"""
        directory = appdirs.user_cache_dir(self.appname, self.appauthor,
                              version=self.version)
        if self.create:
            self._ensure_directory_exists(directory)
        return directory
720609
public static ApplicationContext get() {
        ClassLoader classLoader = getContextClassLoader();
        while (classLoader != null) {
            ApplicationContext applicationContext = contextMap.get(classLoader);
            if (applicationContext != null) {
                return applicationContext;
            }
            classLoader = classLoader.getParent();
        }
        return null;
    }
269141
def platform_cache_dir():
    
    if WIN32:  # nocover
        dpath_ = '~/AppData/Local'
    elif LINUX:  # nocover
        dpath_ = '~/.cache'
    elif DARWIN:  # nocover
        dpath_  = '~/Library/Caches'
    else:  # nocover
        raise NotImplementedError('Unknown Platform  %r' % (sys.platform,))
    dpath = normpath(expanduser(dpath_))
    return dpath
18721
@TargetApi(Build.VERSION_CODES.FROYO)
    public static File getExternalFilesDirForPictures(Context context) {
        return context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    }
514582
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;
    }
631210
def _get_default_cache_dir(self):
        

        return os.path.join(os.path.dirname(__file__), self._DATA_DIR)
588810
@Override
    public Cache getCache(String cacheName) throws CacheException
    {
        if (this.cache == null)
        {
            this.cache = createCache(cacheName);
        }

        return this.cache;
    }
14143
public static Resource getSetupPage(I_SetupUiContext context, String name) {

        String path = CmsStringUtil.joinPaths(context.getSetupBean().getContextPath(), CmsSetupBean.FOLDER_SETUP, name);
        Resource resource = new ExternalResource(path);
        return resource;
    }