In the cordova Android developer application (scroll to the bottom for the device, version, list of plug-ins, all this is absolutely relevant at the time of this writing). I want to mainly store the file on an external SD card and use internal storage if the SDCard is not there. I set my save path:
persistentFS= cordova.file.externalDataDirectory||cordova.file.DataDirectory||fileSystem.root.toURL();
Its final value is the file: ///storage/emulated/0/Android/data/com.fubar.app/files/, the same as cordova.file.externalDataDirectory.
I set: <access origin="cdvfile://*" /> ... <preference name="AndroidPersistentFileLocation" value="Compatibility" /> <preference name="AndroidExtraFilesystems" value="files-external,sdcard,files,documents,cache,cache-external,root" /> in config.xml, <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in AndroidManifest.xml and set various enchantments in index.html Security Metadata. I add that an SD card is inserted, recording is enabled, and I confirm that I can write with it, for example, with a file manager. This contains the Android / data / com.fubar.myapp / files / folder, as it should be.
All for nothing: files are written to - and read from - internal device storage. I read all google in this thread, but nothing brought me closer to the task (some people suggest using a plugin with file systems, but it seems to have been added by a file plugin).
Any clues? TIA, Alf
Edit: Using the adb shell, I see that the external sdcard folder for the application has an absolute path:
`/storage/extSdCard/Android/data/com.fubar.myapp/files`
and call resolveLocalFileSystemURL on
file:///storage/extSdCard/Android/data/com.fubar.myapp/files
succeeds happily. I do not think this is the way to go, because this way is device dependent.
Device: Samsung Galaxy Tab 10.5, candy 5.0.1 using cordova 5.3.1, with plugins: cordova-plugin-device 1.0.1 "Device" cordova-plugin-dialogs 1.1.1 "Notification" cordova-plugin-file 3.0. 0 "File" cordova-plugin-file-transfer 1.3.0 "File Transfer" cordova-plugin-media 1.0.1 "Media" cordova-plugin-whitelist 1.1.0 White List
Host assembly is Linux FC21