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

后端 未结 2 365
忘掉有多难
忘掉有多难 2021-01-28 16:46

I have gone through following links

enter link description here

enter link description here

and i have followed the following tutorial to do cache the im

相关标签:
2条回答
  • 2021-01-28 17:03

    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.

    0 讨论(0)
  • 2021-01-28 17:15

    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.

    0 讨论(0)
提交回复
热议问题