Search code examples
androidimageimageviewpicasso

android:load image from sdcard with picasso


is it possible to use picasso library to load image from sdcard to imageView ?


Solution

  • As picasso doc provided,

    Resources, assets, files, content providers are all supported as image sources.

    You can simply do like it

    String filename = "YOURIMAGE.png";
    String path = "/mnt/sdcard/" + filename;
    Picasso.with(context).load(new File(path)).into(imageView);
    

    Edit

    As @Budius suggested, the better way to access file from disk path, use Enviroment class.

    String filename = "YOURIMAGE.png";
    String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    Picasso.with(context).load(new File(baseDir + File.separator + filename)).into(imageView);
    

    Hope it will work for you.