Skip to content

Instantly share code, notes, and snippets.

@almozavr
Created Oct 1, 2014
Embed
What would you like to do?
Downloads db from non-root devices and opens it via provided sqlite-viewer.
#!/bin/sh
# Script for getting database form device via adb and open in sqlite_client(work with not rooted devices)
#
# While you aren't breaking script execution(CTLR+C),
# each closing of sqlite_client will be download and open database again and again.
#
# Note: if you don't have installed sqliteman override sqlite_client variable with your favorite client
#
# Usage: open_db.sh {app_package} {db_name} {app}
# Example: open_db.sh com.example.app example_app.db Base
sqlite_client="open -a $3"
adb_path=adb
app_package=$1
db_name=$2
dest_path=/tmp/$db_name
ext_storage=$($adb_path shell echo -n \$EXTERNAL_STORAGE)
device_dest_path=$ext_storage/$db_name.db
rm -r $dest_path
$adb_path shell "run-as $app_package cat databases/$db_name >> $device_dest_path"
$adb_path pull $device_dest_path $dest_path
$adb_path shell "rm -r $device_dest_path"
$sqlite_client $dest_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment