Chapter 17: Data Persistence and Sharing
In this chapter, we will look at a couple of different ways to save data to an Android device's permanent storage. Also, for the first time, we will add a second Activity
to our app. It often makes sense when implementing a separate "screen" in our app, such as a settings screen, to do so in a new Activity
. We could go to the trouble of hiding the original UI and then showing the new UI, but this would quickly lead to confusing and error-prone code. So, we will see how to add an Activity
class and navigate the user between them.
In summary, in this chapter, we will do the following:
- Learn about using Android intents to switch between
Activity
classes and pass data - Create a simple (very simple) settings screen in a new
Activity
class for the Note to Self project - Persist the settings screen data using the
SharedPreferences
class - Learn about JavaScript Object Notation (JSON) for serialization
- Explore...