Skip to content

Commit

Permalink
Make Android default persistent file location internal
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Aug 12, 2015
1 parent 19c8a79 commit e281490
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -214,13 +214,13 @@ application's `config.xml` file. To do this, add one of these two lines to

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

Without this line, the File plugin will use `Compatibility` as the default. If
Without this line, the File plugin will use `Internal` as the default. If
a preference tag is present, and is not one of these values, the application
will not start.

If your application has previously been shipped to users, using an older (pre-
1.0) version of this plugin, and has stored files in the persistent filesystem,
then you should set the preference to `Compatibility`. Switching the location to
3.0.0) version of this plugin, and has stored files in the persistent filesystem,
then you should set the preference to `Compatibility` if your config.xml does not specify a location for the persistent filesystem. Switching the location to
"Internal" would mean that existing users who upgrade their application may be
unable to access their previously-stored files, depending on their device.

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-file",
"version": "2.1.1-dev",
"version": "3.0.0",
"description": "Cordova File Plugin",
"cordova": {
"id": "cordova-plugin-file",
Expand Down
19 changes: 18 additions & 1 deletion plugin.xml
Expand Up @@ -21,7 +21,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-file"
version="2.1.1-dev">
version="3.0.0">
<name>File</name>
<description>Cordova File Plugin</description>
<license>Apache 2.0</license>
Expand Down Expand Up @@ -104,6 +104,23 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<js-module src="www/resolveLocalFileSystemURI.js" name="resolveLocalFileSystemURI">
<merges target="window" />
</js-module>

<config-file target="config.xml" parent="/*">
<preference name="AndroidPersistentFileLocation" value="Internal" />
</config-file>

<info>
The Android Persistent storage location now defaults to "Internal". Please check this plugins README to see if you application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

"&lt;preference name="AndroidPersistentFileLocation" value="Compatibility" /&gt;"

to config.xml in order for the application to find previously stored files.

</info>

<!-- android -->
<platform name="android">
Expand Down
2 changes: 1 addition & 1 deletion src/android/FileUtils.java
Expand Up @@ -153,7 +153,7 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Activity activity = cordova.getActivity();
String packageName = activity.getPackageName();

String location = preferences.getString("androidpersistentfilelocation", "compatibility");
String location = preferences.getString("androidpersistentfilelocation", "internal");

tempRoot = activity.getCacheDir().getAbsolutePath();
if ("internal".equalsIgnoreCase(location)) {
Expand Down

1 comment on commit e281490

@aneveucertify
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macdonst - in lines 224 and 225 it says "may be unable to access" and "depending on their device". We are facing that exact problem and trying to reproduce so we can know for sure that we have fixed it. But our test devices are pure Android (Nexus 5 and Nexus 6P) running Android 6.0+. What factors would play in to this? It sounds like many of our users are running Samsung Galaxy S5 and are locked into running Android 5.0, so I suspect that may be one of the affected devices. Any insight into what factors would cause the app to be unable to access previously stored files, versus which devices would not be affected? Many thanks in advance!

Please sign in to comment.