Universal image downloader for external storage files

Hello, I use Universal Image Loader to download images from the device, now it works, but if the path to the file contains a space character, the image does not appear, and the log entries show that there is a FileNotFoundException .

I tried to open the file in a stream using java io and it opens and I can read it.

file name:

 /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20121014-WA0001.jp 

when an exception is thrown
it replaces the space with %20 , and this makes an exception.

My code is:

 ImageLoader.getInstance().displayImage( Uri.fromFile( new File(cursor.getString(cursor.getColumnIndex( MediaStore.Images.Media.DATA)))).toString(), holder.mImage); 

only works if there are no spaces in the path,

Any help

+4
source share
2 answers

Another answer, unfortunately, is not too clear regarding the fact that so after some additional digging fileName I managed to use a local image with imageloader using:

Code example:

 string imgPath = "/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20121014-WA0001.jpg"; String decodedImgUri = Uri.fromFile(new File(imgPath)).toString(); ImageLoader.getInstance().displayImage(decodedImgUri, imageView); 

Android loading a local image with a space in the path and with a universal image downloader also helped solve this problem.

+10
source

I had the same problem and found this solution.

 String uri = fileName.getUri().toString(); String decodedUri = Uri.decode(uri); ImageLoader.getInstance().displayImage(decodedUri, imageView); 
+5
source

All Articles