From 5272c3776d86a613a4f625c24f3808358fa8c742 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Tue, 27 Aug 2019 16:37:00 -0700 Subject: [PATCH] Docs: clarify getSharedPreferences behavior No change to logic, only documentation. This updates Context#getSharedPreferences docs: * Fix a typo ("thead" -> "thread") * Formatting: use

when appropriate, {@link} to other APIs, limit the @param to only a single sentence * Mention getSharedPreferences() may actually perform disk IO (this was undocumented) * Mention Editor#apply() as well as #commit() Fixes: 140137651 Test: make docs Change-Id: I245371d13d4f317c6c522debcdf7938ab783f897 --- core/java/android/content/Context.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index c3dd82729d6d3..658c9b4ff43e7 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -852,11 +852,16 @@ public abstract class Context { * to any callers for the same name, meaning they will see each other's * edits as soon as they are made. * - * This method is thead-safe. + *

This method is thread-safe. * - * @param name Desired preferences file. If a preferences file by this name - * does not exist, it will be created when you retrieve an - * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). + *

If the preferences directory does not already exist, it will be created when this method + * is called. + * + *

If a preferences file by this name does not exist, it will be created when you retrieve an + * editor ({@link SharedPreferences#edit()}) and then commit changes ({@link + * SharedPreferences.Editor#commit()} or {@link SharedPreferences.Editor#apply()}). + * + * @param name Desired preferences file. * @param mode Operating mode. * * @return The single {@link SharedPreferences} instance that can be used