Saturday, October 27, 2018

Android adb access sqlite databse on mobile




Easiest Way: Connect to Sqlite3 via ADB Shell

Original Link:
https://stackoverflow.com/questions/18370219/how-to-use-adb-in-android-studio-to-view-an-sqlite-db


Go to your platform-tools folder in a command prompt

Enter the command adb devices to get the list of your devices

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb devices
List of devices attached
emulator-xxxx   device
3- Connect a shell to your device:

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell
4a- You can bypass this step on rooted device

run-as <your-package-name>
4b- Navigate to the folder containing your db file:

cd data/data/<your-package-name>
cd data/data/com.xamarin.sample.trainapp

to list file and directories
ls


5- run sqlite3 to connect to your db:

sqlite3 <your-db-name>.db
6- run sqlite3 commands that you like eg: