Search code examples
androidpicassoandroid-ionandroid-6.0-marshmallow

Can't load images from external storage in M preview


I have an app that stores it's images on the external storage. This have been working great up until I tried the new M preview.

I use picasso (I even tried Ion) to load the images and I get the images with the "file:///mnt/sdcard/appname/image1.jpg" URI.

I don't get any errors at all, but I'm guessing that M has changed the permissions to read from external storage. I have tried googling but I come up empty.

Writing the images to the external storage works just as normal by the way.


Solution

  • Although siris_cac answer was very well explained it wasn't what caused my problem. Turns out I can't use "file:///mnt/sdcard/appname/image1.jpg" to load the file from external storage in M.

    I guess it might have something to to with http://www.androidpolice.com/2015/05/28/android-m-feature-spotlight-external-storage-can-be-adopted-as-true-internal-storage-or-accessed-normally-with-no-additional-apps/

    I guess I was wrong from the begining not using the Enviroment.getExternalStorageDirectory() when loading images, only when saving them.

    So now to load images I use:

    "file:///" + Environment.getExternalStorageDirectory().getPath() + "/appname/image1.jpg";