To achieve the mission from the beginning of this chapter, we will create a proper mechanism to obtaining shared preferences.
Create a new package called preferences. We will put all preferences related code in that package. For shared preferences management, we will need the following three classes:
- PreferencesProviderAbstract: This is basic abstraction to provide access to SharedPreferences
- PreferencesProvider: This is a PreferencesProviderAbstract implementation
- PreferencesConfiguration: This class is responsible for describing preferences we try to instantiate
Benefit of using this approach is a unified approach to shared preferences access in our application.
Let's define each class as follows: ...