Android : Download images from server and save them on device cache

ぐ巨炮叔叔 提交于 2019-12-02 07:55:18
Hardik Gajjar

Are you properly defining the directory name?

Maybe you didn't declare the directory name properly...

So, can you please check that it's all right ??

 //Find the dir to save cached images
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
        cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"YourDirectoryName");
    else
        cacheDir=context.getCacheDir();
    if(!cacheDir.exists())
        cacheDir.mkdirs();
}

Check your class and make sure your path is right or anything else and tell me after.

In the stack trace it shows a file not found exception. I've seen this happen when the file folder doesn't exist. did you create it first. alternatively, you can use the cache or external folder mentioned above.

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