Investigate app’s data container with ‘run-as’
How many times when testing or developing a mobile you had to verify if correct data is being saved in the correct place? Working on a rooted device is not always possible (or you simply don’t want to root your devices). But fear no more, there is a much simpler solution that was available this whole time.
By installing a ‘debug’ (development) version of the app and running a simple command: adb shell run-as <package name> you get inside your app storage (data container) and inspect its content freely.
Here is a basic example:
1. Run the command to get inside the app container
$ run-as com.xanh.setup
2. Inspect the container, note that run-as will navigate you to /data/data/<package name> location
shell@htc_himauhl:/data/data/com.xanh.setup $ ls cache code_cache shared_prefs
3. To view shared preferences navigate to appropriate folder and with use of cat display content of selected files
- due to a bug, run-as will not work on Samsung devices
- this will only work on ‘debug’ versions of the app
- there is no need to root the device in order to run ‘run-as’