Why is my image not getting cached while using Picasso? When i switch off the internet, the same image doesnt load. I am using this to get the image
final Bitmap m = getImageLoader(context, user).load(uri).get();
where getImageLoader()
is
public Picasso getImageLoader(Context ctx,final User user) {
Picasso.Builder builder = new Picasso.Builder(ctx);
builder.downloader(new OkHttpDownloader(ctx) {
@Override
protected HttpURLConnection openConnection(Uri uri) throws IOException {
HttpURLConnection connection = super.openConnection(uri);
connection.setRequestProperty("X-User",user.getUsername());
connection.setRequestProperty("X-Token",user.getToken());
return connection;
}
});
return builder.build();
}
Does it has something to do with the HTTP headers. Here is my other question regarding this.