My Android Sqlite3 helper batch file for DOS

Back in the day I used to use Windows as my main dev OS (now I like Kubuntu a lot more), and wrote this batch file to help me when I had to investigate a database on a device. I found it today when I was helping Seren out with one of her apps, and thought I would post it up as it may be useful to someone.

cls
@echo off
echo. %1
echo. copy this string to open your db in sqlite3
echo.
echo. sqlite3 /data/data/<YOUR PACKAGE NAME HERE>/databases/<YOUR DB NAME>.db
echo. --
echo.
echo. within sqlite3 paste these three lines, they will:
echo. 1. turn column mode on so that your data is presented nicely
echo. 2. turn the headers on so you can tell which columns are which
echo. 3. tell you the tables within the database
echo.
echo. .mode column
echo. .headers on
echo. .tables
echo. --
echo.
echo. These next 4 lines are just reminders of how to do basic database manipulation in SQL
echo.
echo. select * from event where parent_id="4610";
echo. delete from event where event_id="5462";
echo. insert into event (id, something) values (4, sdfv);
echo. update event set id=43, something=[23]
echo. 
if "%1" == "-e" goto :startemulator
if "%1" == "-d" goto :startdevice
if "%1" == "" goto :startdevice
goto :end

:startemulator
echo. starting emulator shell
adb -e shell
goto :end

:startdevice
echo. starting device shell
adb -d shell
goto :end

:end

Leave a Reply