ImageLoader.getInstance().getDiscCache().get(imageUrl) returns different paths

孤人 提交于 2019-12-22 00:12:08

问题


  1. Call to cache

    ImageLoader.getInstance().loadImage(cnt, imageUrl, new ImageLoadingListener()

  2. /mnt/sdcard/Android/data/[package]/cache/40d1dxbmdamufgcs742bjraew is created

  3. ImageLoader.getInstance().getDiscCache().get(imageUrl) - returns /mnt/sdcard/Android/data/[package]/cache/40d1dxbmdamufgcs742bjraew -> OK
  4. reboot device

  5. ImageLoader.getInstance().getDiscCache().get(imageUrl) - returns /data/data/[package]/cache/40d1dxbmdamufgcs742bjraew -> KO (THIS FOLDER IS CREATED BUT ITS" EMPTY)


回答1:


Thanks to Doctoror Drive

https://github.com/nostra13/Android-Universal-Image-Loader/tree/master/library/src/com/nostra13/universalimageloader/core

/** * Returns application cache directory. Cache directory will be created on SD card * ("/Android/data/[app_package_name]/cache") if card is mounted. Else - Android defines cache directory on * device's file system. * * @param context Application context * @return Cache {@link File directory} */

public static File getCacheDirectory(Context context) {
        File appCacheDir = null;
        if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
            appCacheDir = getExternalCacheDir(context);
        }
        if (appCacheDir == null) {
            appCacheDir = context.getCacheDir();
        }
        return appCacheDir;
    }


来源:https://stackoverflow.com/questions/16609277/imageloader-getinstance-getdisccache-getimageurl-returns-different-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!