Is it possible to access SharedPreferences from Appium?

We have lots of functionality that sits behind feature toggles or A/B Test configurations. All of these toggles can be changed from the app via a dedicated debug screen, but the underlaying settings are stored in Android’s SharedPreferences. So currently as part of the test scenario, we navigate to this debug screen and change those settings manually. This is taking time, running time, but as well as development time.

Since all of the settings are stored in the SharedPreferences, we could cut on time by programmatically configuring the SharedPreferences of interest before the test starts.

There’s an old thread from 2016 asking exactly the same question: Can appium interact with SharedPreference

Is there any progress on that? Is there a workaround one can use to manipulate the SharedPreferences from Appium?

Hope to hear soon from you guys
Thank you

Shared preferences is just a file inside of your application bundle. You could pull it from there and parse the content. The only requirement for the application under test to be able to pull this file from there is that it should be debuggable.

I see, I guess that will work, but it would require more manual work, eg.: parsing and persisting the settings, I was wondering whether Appium provides a bridge over the SharedPreferences, something like: driver.setPreference("key", "value") , or alternatevely, if there was a way to get a android.content.Context, then one could directly get an instance of SharedPreferences and interact with the settings in a safe way.

Unfortunately Appium does not have anything like that.