Read Android Data Folder Without Rooting

I got my new galaxy s3 and I am all excited doing new android development. I fire up the adb shell to look around and I see this:

dennis@foofive ~ $ adb shell shell@android:/ $ ls -al ... drwxrwx--x system system 2012-09-24 23:38 data ... shell@android:/ $ cd data/ shell@android:/data $ ls opendir failed, Permission denied 1 2 3 4 5 6 7 8 dennis @ foofive ~ $ adb shell shell @ android : / $ ls - al . . . drwxrwx -- x system system 2012 - 09 - 24 23 : 38 data . . . shell @ android : / $ cd data / shell @ android : / data $ ls opendir failed , Permission denied

Grrrr. Ok so I can’t access the data folder because it is read protected. What do I do now? I can root the phone, but I don’t really want to do that for various reasons. All I really want is to see into my data folder application directories, be able to remove test files such as databases and preferences.

Turns out there is a simple solution, the run-as command.

run-as com.your.package ls -l /data/data/com.your.package run-as com.your.package rm /data/data/com.your.package/databases/mydatabase.db 1 2 run - as com .your .package ls - l / data / data / com .your .package run - as com .your .package rm / data / data / com .your .package / databases / mydatabase .db

That will allow you to run commands as your app. You can also use run-as in interactive mode.

run-as com.your.package shell@android:/data/data/com.your.package $ ls cache databases lib shared_prefs rm databases/mydatabase.db 1 2 3 4 5 6 7 run - as com .your .package shell @ android : / data / data / com .your .package $ ls cache databases lib shared_prefs rm databases / mydatabase .db

Interactive mode will drop you into the data folder for your app. You can navigate from there.

For the run-as command to work the app must be debuggable. This means that run-as will work for apps that you are developing and have deployed through eclipse and for any apps that have been released with the debuggable flag turned on. It will not work for most android system and commercially released apps. Sorry, no hacking your favorite app this way.

shell@android:/ $ run-as com.android.backupconfirm run-as: Package 'com.android.backupconfirm' is not debuggable 1 2 shell @ android : / $ run - as com .android .backupconfirm run - as : Package 'com.android.backupconfirm' is not debuggable

Hope this helps save you some time and frustration.