anup anup - 1 year ago 110
Java Question

How to use Picasso to open a image stored locally in android?

I want my app to be able to retrieve and display images from the device storage when there is no internet available.So when the app loads for the 1st time with internet I download the images into a folder and later when there is no internet I ask it to open from the local storage.
My images are stored at this location


On volley response I call the following code which is used to set the adapter for the recyclerview.

public ArrayList showJSON(String json) {
ParseJSON pj = new ParseJSON(json);

image_url = ParseJSON.img_url;
mag_version = ParseJSON.magversion;
download_path = ParseJSON.download_url;
sample_url = ParseJSON.sample_url;

for (String img : image_url) {

File sh_images = new File(Environment.getExternalStorageDirectory()+"/shatayushi");
String[] img_files = sh_images.list(new FilenameFilter() {
public boolean accept(File dir, String filename)
if (filename.toLowerCase().endsWith(".jpg"))
return true;
}else {
return false;

String stored_imgurl[]= new String[img_files.length];

for (int i=0; i<img_files.length;i++)


ArrayList android_version = new ArrayList<>();

for (int i = 0; i < image_url.length; i++) {
MagazineVersion magazineVersion = new MagazineVersion();
return android_version;


And on response of volley I call the above method as follows:-

ArrayList androidVersions = showJSON(response);

DataAdapter adapter = new DataAdapter(DisplayMagazine.this, androidVersions);

And inside my DataAdapter I use Picasso to display the images as follows:-

Picasso.with(context).load(magazineVersions.get(position).getStored_imgurl()).resize(400, 500).into(holder.iv_magazine);

This is a part of my log cat:-

07-30 13:44:12.633 16766-16766/com.inevitablesol.shatayushiapp
I/dalvikvm: DexOpt: illegal method access (call
Landroid/support/v7/widget/RecyclerView$ViewHolder;.isUpdated ()Z from
07-30 13:44:12.633 16766-16766/com.inevitablesol.shatayushiapp
I/dalvikvm: Could not find method$ViewHolder.isUpdated,
referenced from method
07-30 13:44:12.633 16766-16766/com.inevitablesol.shatayushiapp
W/dalvikvm: VFY: unable to resolve virtual method 17450:
Landroid/support/v7/widget/RecyclerView$ViewHolder;.isUpdated ()Z

Which says illegal method access and Could not find method$ViewHolder.isUpdated
, referenced from method

Can anyone please help me with a solution I am new to programming.Thank you.

Answer Source

you can use like below way to LOAD FILE FROM SDCARD/Device storage: in your case you have to identify if file is available in storage or not. then decide to load from web or storage

Picasso.with(context).load(new File(...)).into(imageView3);

make sure you are passing fullpath of image

read from documentaion

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download