Exemple #1
0
 private void initCacheDirectory() {
   String cacheDirName = null;
   // SD card
   cacheDirName = createCacheDir(Environment.getExternalStorageDirectory(), CACHE_BASE_DIR_NAME);
   // non-standard SD mount points
   if (cacheDirName == null) {
     for (String dirname : Scanner.SD_MOUNT_POINTS) {
       cacheDirName = createCacheDir(new File(dirname), CACHE_BASE_DIR_NAME);
       if (cacheDirName != null) break;
     }
   }
   // internal flash
   if (cacheDirName == null) {
     File cacheDir = mActivity.getCacheDir();
     if (!cacheDir.isDirectory()) cacheDir.mkdir();
     cacheDirName = createCacheDir(cacheDir, null);
     // File cacheDir = mActivity.getDir("cache", Context.MODE_PRIVATE);
     //			if (cacheDir.isDirectory() && cacheDir.canWrite())
     //				cacheDirName = cacheDir.getAbsolutePath();
   }
   // set cache directory for engine
   if (cacheDirName != null) {
     log.i(cacheDirName + " will be used for cache, maxCacheSize=" + CACHE_DIR_SIZE);
     synchronized (this) {
       setCacheDirectoryInternal(cacheDirName, CACHE_DIR_SIZE);
     }
   }
 }