summaryrefslogtreecommitdiff
path: root/core/java/android/content/Context.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-12-07 19:25:19 -0700
committerJeff Sharkey <jsharkey@android.com>2015-12-07 19:25:25 -0700
commit6a6cdafaec56fcd793214678c7fcc52f0b860cfc (patch)
tree8875835dd240914d9bf7344dc5f2c0c35dc77b40 /core/java/android/content/Context.java
parentce14cd01411c384b3b979a9f662bf3cd5f9e7183 (diff)
APIs to obtain SharedPreferences paths.
Needed for apps that want to migrate SharedPreferences from CE to DE storage. Note that a device will only ever enter a CE mode with a factory reset, so apps should only be using these APIs when they want to migrate files to a consistent location on non-FBE devices for simplicity. Bug: 25503089 Change-Id: Ic846215da1617d116a048e036415ac7ad523b770
Diffstat (limited to 'core/java/android/content/Context.java')
-rw-r--r--core/java/android/content/Context.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 6cc549745f66..4c7e853491cc 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -606,13 +606,13 @@ public abstract class Context {
public abstract String getPackageCodePath();
/**
- * {@hide}
- * Return the full path to the shared prefs file for the given prefs group name.
- *
- * <p>Note: this is not generally useful for applications, since they should
- * not be directly accessing the file system.
+ * @hide
+ * @deprecated use {@link #getSharedPreferencesPath(String)}
*/
- public abstract File getSharedPrefsFile(String name);
+ @Deprecated
+ public File getSharedPrefsFile(String name) {
+ return getSharedPreferencesPath(name);
+ }
/**
* Retrieve and hold the contents of the preferences file 'name', returning
@@ -654,6 +654,7 @@ public abstract class Context {
* @return The single {@link SharedPreferences} instance that can be used
* to retrieve and modify the preference values.
*
+ * @see #getSharedPreferencesPath(String)
* @see #MODE_PRIVATE
* @see #MODE_WORLD_READABLE
* @see #MODE_WORLD_WRITEABLE
@@ -739,6 +740,20 @@ public abstract class Context {
public abstract File getFileStreamPath(String name);
/**
+ * Returns the absolute path on the filesystem where a file created with
+ * {@link #getSharedPreferences(String, int)} is stored.
+ * <p>
+ * The returned path may change over time if the calling app is moved to an
+ * adopted storage device, so only relative paths should be persisted.
+ *
+ * @param name The name of the shared preferences for which you would like
+ * to get a path.
+ * @return An absolute path to the given file.
+ * @see #getSharedPreferences(String, int)
+ */
+ public abstract File getSharedPreferencesPath(String name);
+
+ /**
* Returns the absolute path to the directory on the filesystem where files
* created with {@link #openFileOutput} are stored.
* <p>