Nebular Dust Nebular Dust - 3 months ago 19
Android Question

Android 5.1.1 app doesn't see local files

I made a website and turned it into Android app, using Phonegap website. I have files stored on a local storage on ASUS TF300 tablet, and I need an app to access them. To access the files I use links like that:

file:///sdcard/original_img/3_1_5.jpg

Now the funny part. If I open this link in Chrome, Firefox or any other browser on my tablet - the image loads up. But if I launch an app with the same link in its index.html, the image doesn't load at all.

What could it be? Is a storage path somehow different for the apps and for browsers?

Answer

Looks like you need to add this into your app AndroidManifest.xml :

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     ...
 </manifest>

UPDATE from chat conversation (based on this thread) :

Add config.xml:

<preference name="AndroidPersistentFileLocation" value="Compatibility" /> 
<preference name="AndroidExtraFilesystems" value="sdcard,cache" />

file pathes should be like following:

 file:///sdcard/<path>