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 instance to our app. It often makes sense when implementing a separate "screen", such as a "Settings" screen, in our app to do so in a new Activity instance. We could go to the trouble of hiding the original UI and then showing the new UI in the same Activity, as we did in Chapter 4, Getting Started with Layouts and Material Design, but this would quickly lead to confusing and error-prone code. So, we will see how to add another Activity instance and navigate the user between them.
In this chapter, we will do the following:
- Learn about the Android
Intentclass to switchActivityinstances and pass data between them - Create a very simple settings screen in a new
Activityinstance - Persist the settings screen data using the
SharedPreferencesclass - Learn...