using-sharedpreferences
, and open up the
projects
folder. Next, open the
organizedsimplenotes
app under the
starter
folder. Allow the project to sync,
download dependencies and set up the workplace environment. Run the app on a
device or in a simulator. For now, ignore any warnings in the code.
The app allows you to create, edit and delete notes that are saved in the internal file
system. In the options menu items, there is an option to change the background
color. You can also filter the notes by priority, or sort them by a specific sort order.
Select a new background color, sort order and one or more priority filters. Now, quit
the app and rerun it.
When the app reloads, the background color you selected persists. That is because
the background color you selected was saved to prefs and applied when the app was
rerun. The sort order and priority filters reset to defaults. They were not stored in
prefs.
Saving Data on Android
Chapter 2: Shared Preferences
raywenderlich.com
43
To see the saved value for the background color, open the
Do'stlaringiz bilan baham: |