Update saving persistent state documentation

Updated the code snippet for saving persistent state to make the code
workable.
 - Update usage for getSharedPreferences.
 - Fix NPE when access mPrefs

Bug: 181924060
Test: Build
Change-Id: I695ad13282d5d9adb4a79108dfd1b6aae7b5a167
This commit is contained in:
Jeff Chang
2021-03-10 17:03:12 +08:00
parent 238ab956c1
commit 46eb2d09b7

View File

@@ -642,7 +642,7 @@ import java.util.function.Consumer;
* protected void onCreate(Bundle savedInstanceState) {
* super.onCreate(savedInstanceState);
*
* SharedPreferences mPrefs = getSharedPreferences();
* mPrefs = getSharedPreferences(getLocalClassName(), MODE_PRIVATE);
* mCurViewMode = mPrefs.getInt("view_mode", DAY_VIEW_MODE);
* }
*