*TL;DR Summary*

We should switch the default for the Cordova Android File System to be on
internal storage, not the SD Card (or emulated SD card).


*Long Version*

Currently in Cordova Android when you use this code "window.
requestFileSystem(PERSISTENT, 0, win, fail);" the root file system path
that is returned is "/storage/emulated/0" i.e. "/sdcard".

Why you may ask? Because back in 2010 or so Bryce Curtis and I argued that
we should use the external storage location because internal storage was
not very large on Android 2.x and we didn't want to have developers filling
up the devices limited internal storage. Joe Bowser argued against it
because of issues with the SD Card on Android but was eventually out voted.

Now, I'm prepared to admit that Bryce was wrong (see what I did there?). I
feel that the default behaviour for "window.requestFileSystem(PERSISTENT,
0, win, fail);" should be to resolve to a location on internal storage that
meets the following requirements:

a) private to the application

b) removed when the application is uninstalled

c) lines up with what we have on iOS and WP

In fact you can get this behaviour right now but setting the following
preference in config.xml:

<preference name="AndroidPersistentFileLocation" value="Internal" />

This gets you a root file path of "/data/data/<android
package>/files/files/". The double "files" is an issue but we can probably
ignore it for now.

If a user wants the old behaviour they only need to make the preference:

<preference name="AndroidPersistentFileLocation" value="Compatibility" />

and the original behaviour will be retained.

What I'm advocating for is to make internal storage the default behaviour
for Cordova Android.


*Code Changes*

I've already taken a brief look into this and I feel the change is
extremely minor. We need only change the default return value from
"compatibility" to "internal" at line 156 of FileUtils.java (https://github
.com/apache/cordova-plugin-file/blob/master/src/android/FileUtils.java#L156
).

If we wanted to make the change explicit to the user we could change plugin.
xml to add the preference to config.xml as well.

Thoughts, comments, applause?
Simon Mac Donald
http://hi.im/simonmacdonald

Reply via email to