In a cordova android app (scroll to the bottom for device,version, plugin list, all of it quite up-to-date as of this writing) I want to preferentially store file on the external SDCard and use internal storage if SDCard not there. I am setting my save path to:
persistentFS= cordova.file.externalDataDirectory||cordova.file.D ataDirectory||fileSystem.root.toURL();
Its eventual value is file:///storage/emulated/0/Android/data/com.fubar.app/files/, same as cordova.file.externalDataDirectory.
I have 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_ST ORAGE" />
in AndroidManifest.xml and set various enchantments in index.html Security metatag. I add that a SDcard is inserted, write-enabled and I confirm that I can write to it with - for example - a file manger. It contains the Android/data/com.fubar.myapp/files/ folder, as it should.
All for nothing: files get written to - and read from - the internal device storage. I have read all google could scavenge on this topic but nothing has brought me closer to the task (some folks suggest using the file-system-roots plugin, but it appears to have been subsumed by the file plugin).
Using adb shell, I can see that the external sdcard files folder for the app has an absolute path of:
/storage/extSdCard/Android/data/com.fubar.myapp/files
and calling resolveLocalFileSystemURL on
file:///storage/extSdCard/Android/data/com.fubar.myapp/files
happily succeeds. I do not think that is the way to go, as that path is device dependent.
Any hints? TIA, alf
Edit:
Device: Samsung Galaxy tab 10.5, lollipop 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 "Whitelist"
Build host is Linux FC21
persistentFS= cordova.file.externalDataDirectory||cordova.file.D ataDirectory||fileSystem.root.toURL();
Its eventual value is file:///storage/emulated/0/Android/data/com.fubar.app/files/, same as cordova.file.externalDataDirectory.
I have 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_ST ORAGE" />
in AndroidManifest.xml and set various enchantments in index.html Security metatag. I add that a SDcard is inserted, write-enabled and I confirm that I can write to it with - for example - a file manger. It contains the Android/data/com.fubar.myapp/files/ folder, as it should.
All for nothing: files get written to - and read from - the internal device storage. I have read all google could scavenge on this topic but nothing has brought me closer to the task (some folks suggest using the file-system-roots plugin, but it appears to have been subsumed by the file plugin).
Using adb shell, I can see that the external sdcard files folder for the app has an absolute path of:
/storage/extSdCard/Android/data/com.fubar.myapp/files
and calling resolveLocalFileSystemURL on
file:///storage/extSdCard/Android/data/com.fubar.myapp/files
happily succeeds. I do not think that is the way to go, as that path is device dependent.
Any hints? TIA, alf
Edit:
Device: Samsung Galaxy tab 10.5, lollipop 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 "Whitelist"
Build host is Linux FC21
Aucun commentaire:
Enregistrer un commentaire