android:load image from sdcard with picasso

若如初见. 提交于 2019-12-11 06:50:57

问题


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


回答1:


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.




回答2:


You need to first convert your image to a Uri, and then load it using Picasso the same way you did for any images.



来源:https://stackoverflow.com/questions/28983659/androidload-image-from-sdcard-with-picasso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!