You can do this using OkHttp and Picasso:
public class APP extends Application{ public static OkHttpDownloader okHttpDownloader; @Override public void onCreate() { super.onCreate(); Picasso.Builder b = new Picasso.Builder(this); okHttpDownloader = new OkHttpDownloader(this); b.downloader(okHttpDownloader); Picasso.setSingletonInstance(b.build()); } }
Then get the file from OkHttp's local cache:
Downloader.Response res = APP.okHttpDownloader.load(Uri.parse(your image Url),0); Log.i(TAG,"Get From DISK: " + res.isCached() ); storeImageFile(res.getInputStream());
source share