In this recipe, we will make use of the Android KTX library developed by Google, providing a set of useful extensions and utilities dedicated to Android app-development. We are going to apply extension functions that allow us to operate on the SharedPreferences class in a clean and robust way.
Easy operations on SharedPreferences
Getting ready
In order to make use of the Android KTX library, we need to add it to the project dependencies. In our case, we will need it in the android-test module. We can add it with the following declaration:
androidTestImplementation 'androidx.core:core-ktx:1.0.+'
We are going to implement the Android instrumented test case in order to verify the effects of the operations we'll...