Android ADB shell script – how to extract all SharedPreferences
I need to run a script in debugging mode, which will pull all SharedPreferences into a folder. According to my research, I can only exit the debugging version. I try to get such sharing preferences from rootless phones:
$adb shell
$adb run-as mypackagename
Then I can traverse / data / data / mypackagename / shared_ prefs
But I want to be able to put it into the script. I can only call ADB pull from outside the ADB shell. How can I share it in the debugging application_ Prefs pull the entire folder from the normal non root user device? There must be a way, because what does Facebook setho do?
This problem is about retrieving shared preferences, not database retrieval
resolvent:
I created the following shell script
#!/bin/bash
pname=$1
if [ -z "${pname}" ]; then
echo "Please enter a package name"
exit 1
fi
adb shell "run-as $pname chmod 776 shared_prefs"
adb pull /data/data/$pname/shared_prefs ./${pname}_shared_prefs
adb shell "run-as $pname chmod 771 shared_prefs"
Name it pullsharedprefs.sh (or whatever you want), and then run the command from the terminal:
chmod +x pullsharedprefs.sh
./pullsharedprefs.sh some.package.name
shared_ Prefs will be pulled to the current working directory and named {package name}_ shared_ prefs
Test with genymotion (Android 5.1.1)