Stack Overflow archive
4 scoreaccepted

android adb shell script - how to pull all sharedpreferences

score
4
question views
3K
license
CC BY-SA 3.0

I created the following shell script

bash
#!/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 from terminal run the command:

bash
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


Tested using genymotion (Android 5.1.1)

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.