Posts

Showing posts from May, 2019

How to Set Shared Preferences in Espresso Test for Kotlin and Java

Image
I have experienced Espresso and needed to deep dive into Shared Preferences
just because it is one of the main parameters used in the application we developed. As a long search in the online sources but there are some pretty old documents for Espresso with Java and very few documents about Espresso with Kotlin. In this post, I want to share my experiences with setting Shared Preferences with Kotlin and Java and how you can use it in your test design. You can follow up the steps for your test project.
Shared Preferences is a way to store user data in local devices so it has been supported since the very early version of Android. Shared Preferences can be stored in the default file or custom file. 
Using Default File for Shared PreferencesIf your application uses the default file it should stores the shared data in the default file provide by Android as in the following path in the device:
/data/data/com.package.name/shared_prefs/com.package.name_preferences.xmlThis is the source code for…