Following my previous post it appears that it is not possible to write into the following app's data folders which are identified by:
cordova.file.dataDirectory
cordova.file.externalDataDirectory
Which are translated respectively into:
file:///data/data/my_app_id/files
file:///storage/sdcard0/Android/data/my_id_app/files/
and which both map to the same destination (the internal Android storage space):
.../sdcard0/Android/data/my_id_app/files/
When the app is installed, inside .../sdcard0/Android/data/
a directory named my_id_app
is created with two subdirectories files
and cache
. The files
directory has no write permissions:
If I try to write into
cordova.file.dataDirectory
no error is reported. The operation seems to have been successful but it is not. I cannot write into this directory even if the phone is rooted.If I try to write into
cordova.file.externalDataDirectory
error code = 1
(file not found) is raised. Nothing can be written into this directory. I can read/write into this directory only if the phone rooted.
I did these tests on my Samsung S3 Mini (Android 4.1.2) and Phonegap Build 6.2. Nothing about these kind of permissions restrictions is specified or clearly explained in the official documentation at cordova-plugin-file.
I would like to write into the app's data directory because it's the only directory that it's removed when the user uninstalls the app. I don't want to leave pieces of my app into the user's phone if he wants to remove the app.
If these directories are not writable where should I save the files the app downloads and be sure they are removed when the app is uninstalled?
Any thoughts, explanations, suggestions? I'm missing something?