Hello I use Universal Image Loader to load images from the device , now it works, but if the file path contains a "space character" the image does not get displayed and log records show that there is a FileNotFoundException
.
I tried to open the file in a thread using java io and it opens and I can read it.
the file name :
/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20121014-WA0001.jp
when the Exception thrown
it replace the space with a %20
and this what makes the exception thrown.
My code:
ImageLoader.getInstance().displayImage(
Uri.fromFile(
new File(cursor.getString(cursor.getColumnIndex(
MediaStore.Images.Media.DATA)))).toString(),
holder.mImage);
works only when no spaces in the path ,
Any help
The other answer unfortunately isn't too clear on what fileName
is so after some additional digging I managed to use local image with imageloader using:
Sample Code:
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 local image with space in path and with universal image loader also helped to resolve this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With