Skip to content

Instantly share code, notes, and snippets.

@davethomas11
Created February 6, 2017 16:14
Show Gist options
  • Save davethomas11/3e8a45337f7b5a41b7e52a3319f02fd2 to your computer and use it in GitHub Desktop.
Save davethomas11/3e8a45337f7b5a41b7e52a3319f02fd2 to your computer and use it in GitHub Desktop.
Pull a database from your Android device
#!/bin/bash
if [ -z "$1" ]; then
echo "Please specify DB file name"
echo "usage $0 [Database File] [App Package]"
exit 1
fi
if [ -z "$2" ]; then
echo "Please specify the package name to run as"
echo "usage $0 [Database File] [App Package]"
exit 1
fi
devices=($(adb devices -l | sed '/List of devices/d' | awk '{print $1}'))
if [ ${#devices[@]} -gt 1 ]; then
echo "Pick device to pull db from:"
select device in ${devices[@]};
do
break;
done
else
device=${devices[0]}
fi
adb -s $device exec-out run-as $2 cat databases/$1 > $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment