How to examine SharedPreferences from adb shell?

an0 picture an0 · Aug 7, 2009 · Viewed 31.6k times · Source

Now that we can Examining sqlite3 Databases from a Remote Shell, is it possible to examine SharedPreferences from adb shell? Since it would be much more convenient to examine and manipulate SharedPreferences from command line when debugging.

Or put in another way, in what files SharedPreferences are saved, and how to view and modify these files?

Answer

an0 picture an0 · Aug 7, 2009

Fine, I found the file just after I raised the question above. (It seem asking questions publicly stimulate me to search answers by myself much more diligently, since I don't want my dear peers to view me as a lazy programmer.)

It is an XML file under /data/data/your.app.package.name/shared_prefs, and the file name is your.app.package.name_preferences.xml. It is really easy to modify the preferences when you figure out that the content is just a key-value map.