Drawable.createFromPath

I was trying to load an image from the sdcard. From the same directory I managed to open sound files and play them, but for some reason it didn’t work for the image. After trying everything it turned out that

MediaPlayer.create(this, Uri.parse("file:///sdcard/app/a.mp3"));

works, but

Drawable.createFromPath("file:///sdcard/app/a.jpg");

doesn’t work. Instead of this path, one should use:

Drawable.createFromPath("/sdcard/app/a.jpg");

This finally works! BTW it also works for the MediaPlayer.

Leave a Reply

Your email address will not be published. Required fields are marked *