Android - Unable to open content: file:///storage/emulated/0

Viewed 97862

I've a widget with nine-patch image background. The image was saved in /sdcard/mydir/bgs.

When I try to load a image with setImageViewUri method, I've this error:

Unable to open content: file:///storage/emulated/0/sdcard/mydir/bgs

..

then

...

open failed: EACCES (Permission denied)

This appears only on the the home screen and only with Nexus 10 and Nexus 7 (with latest launcher 4.4 this bug not exist). I've also have some RemoteViews on my application and all works correctly.

I've also added into manifest either READ_EXTERNAL_STORAGE, either WRITE_EXTERNAL_STORAGE.

How can I solve?

UPDATE: I've inspect the method setImageViewUri and I've found that it changes the path of my file.

if (value != null) {
            // Resolve any filesystem path before sending remotely
            value = value.getCanonicalUri();
            if (StrictMode.vmFileUriExposureEnabled()) {
                value.checkFileUriExposed("RemoteViews.setUri()");
            }
        }

This method receive my value (/sdcard/mydir/bgs) and changes it into (storage/emulated/0/sdcard/mydir/bgs). But this file not exists into system via adb.

4 Answers
Related