How to Examine and Modify SharedPreferences from adb Shell

How to Examine and Modify SharedPreferences from adb Shell

21 May 2024 Stephan Petzl Leave a comment Tech-Help

Debugging and adjusting SharedPreferences directly from the adb shell can significantly streamline the development process. This guide will walk you through the steps to view and modify SharedPreferences files from the command line, making it easier to manage your app’s settings during development.

Understanding SharedPreferences File Location

SharedPreferences are stored as XML files in your app’s data directory. Specifically, you can find them under:


The filename typically follows the pattern:

Viewing SharedPreferences

To view the contents of a SharedPreferences file, you can use the following command:

$ adb shell
$ run-as
$ cat /data/data/

This will display the XML content of the SharedPreferences file, allowing you to inspect the key-value pairs.

Modifying SharedPreferences

To modify the SharedPreferences file, you can pull it to your local machine, edit it, and push it back. Here’s a convenient one-liner that accomplishes this:
adb pull /data/data/${APP_ID}/shared_prefs/${APP_ID}_preferences.xml /tmp/${APP_ID}_preferences.xml && vim /tmp/${APP_ID}_preferences.xml && adb push /tmp/${APP_ID}_preferences.xml /data/data/${APP_ID}/shared_prefs/

This command sequence pulls the SharedPreferences file, opens it in vim for editing, and then pushes the modified file back to the device.

Handling Permissions

If you encounter “Permission Denied” errors, try using the exec-out command:

adb exec-out run-as cat /data/data/

This method ensures that you have the necessary permissions to access the file.


Managing SharedPreferences through the adb shell can be a powerful tool for debugging and development. By understanding where these files are stored and how to view and modify them, you can streamline your workflow and quickly make necessary adjustments.

Enhancing Your Testing Workflow with Repeato

For a more comprehensive and automated approach to testing your Android and iOS apps, consider using Repeato. Repeato is a no-code test automation tool that leverages computer vision and AI to create, run, and maintain automated tests efficiently. With features like built-in ADB support and script steps for executing ADB commands, Repeato can help you automate the process of inspecting and modifying SharedPreferences, along with other testing tasks.

Learn more about how Repeato can enhance your testing workflow by visiting our documentation.

Like this article? there’s more where that came from!