Skip to content

Instantly share code, notes, and snippets.

@antoni
Created April 13, 2014 08:38
Show Gist options
  • Save antoni/10574869 to your computer and use it in GitHub Desktop.
Save antoni/10574869 to your computer and use it in GitHub Desktop.
Pulls SQlite database from Android device
#!/bin/bash
REQUIRED_ARGS=2
PULL_DIR="./"
ADB_PATH=`which adb`
if [ $? -ne 0 ]
then
echo "Could not find adb!"
exit 1
fi;
if [ $# -ne $REQUIRED_ARGS ]
then
echo ""
echo "Usage:"
echo "adb_db_pull.sh [package_name] [db_name]"
echo "eg. adb_db_pull.sh lt.appcamp.impuls impuls.db"
echo ""
exit 1
fi;
echo""
cmd1="$ADB_PATH -d shell 'run-as $1 cat /data/data/$1/databases/$2 > /sdcard/$2' "
cmd2="$ADB_PATH pull /sdcard/$2 $PULL_DIR"
echo $cmd1
eval $cmd1
if [ $? -eq 0 ]
then
echo ".........OK"
fi;
echo $cmd2
eval $cmd2
if [ $? -eq 0 ]
then
echo ".........OK"
fi;
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment