summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-08-25 13:13:36 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2010-08-25 13:13:36 -0700
commitedf32d01316bd3432c023f17747461b08ae36375 (patch)
tree3f5ab0cd80b55712a716c975ddbbf7fcd9a43eab /core
parent8eb16af29303cda190133a1d220b9ecd9341e261 (diff)
downloadframeworks_base-edf32d01316bd3432c023f17747461b08ae36375.zip
frameworks_base-edf32d01316bd3432c023f17747461b08ae36375.tar.gz
frameworks_base-edf32d01316bd3432c023f17747461b08ae36375.tar.bz2
Start of SharedPreferences$Editor.startCommit()
No implementation yet, just the interface. Change-Id: Idf9934b445da1fb72b79f0192218b47c0a7f5a34
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/ContextImpl.java7
-rw-r--r--core/java/android/content/SharedPreferences.java37
2 files changed, 41 insertions, 3 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 2870c50..7b35e7f 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -2840,6 +2840,11 @@ class ContextImpl extends Context {
}
}
+ public void startCommit() {
+ // TODO: implement
+ commit();
+ }
+
public boolean commit() {
boolean returnValue;
@@ -2914,7 +2919,7 @@ class ContextImpl extends Context {
public Editor edit() {
return new EditorImpl();
}
-
+
private FileOutputStream createFileOutputStream(File file) {
FileOutputStream str = null;
try {
diff --git a/core/java/android/content/SharedPreferences.java b/core/java/android/content/SharedPreferences.java
index a15e29e..f1b1490 100644
--- a/core/java/android/content/SharedPreferences.java
+++ b/core/java/android/content/SharedPreferences.java
@@ -151,14 +151,47 @@ public interface SharedPreferences {
* {@link SharedPreferences} object it is editing. This atomically
* performs the requested modifications, replacing whatever is currently
* in the SharedPreferences.
- *
+ *
* <p>Note that when two editors are modifying preferences at the same
* time, the last one to call commit wins.
- *
+ *
+ * <p>If you don't care about the return value and you're
+ * using this from your application's main thread, consider
+ * using {@link #startCommit} instead.
+ *
* @return Returns true if the new values were successfully written
* to persistent storage.
*/
boolean commit();
+
+ /**
+ * Commit your preferences changes back from this Editor to the
+ * {@link SharedPreferences} object it is editing. This atomically
+ * performs the requested modifications, replacing whatever is currently
+ * in the SharedPreferences.
+ *
+ * <p>Note that when two editors are modifying preferences at the same
+ * time, the last one to call commit wins.
+ *
+ * <p>Unlike {@link #commit}, which writes its preferences out
+ * to persistent storage synchronously, {@link #startCommit}
+ * commits its changes to the in-memory
+ * {@link SharedPreferences} immediately but starts an
+ * asynchronous commit to disk and you won't be notified of
+ * any failures. If another editor on this
+ * {@link SharedPreferences} does a regular {@link #commit}
+ * while a {@link #startCommit} is still outstanding, the
+ * {@link #commit} will block until all async commits are
+ * completed as well as the commit itself.
+ *
+ * <p>If you call this from an {@link android.app.Activity},
+ * the base class will wait for any async commits to finish in
+ * its {@link android.app.Activity#onPause}.</p>
+ *
+ * @return Returns true if the new values were successfully written
+ * to persistent storage.
+ */
+ void startCommit();
}
/**