2

I'm trying to create a script to simplify data checking with sqlite. For me it's quite troublesome to write :

adb shell
sqlite /data/data/my.package.name/databases/mydatabse.db

every time I want to check something in the db (and in the beginning phases of db development this is quite often), especially because TAB completion doesn't seem to work (at least for me). So I tried to write a script to automatically open the database for me, but the android documentation clearly states that:

shell [<shellCommand>] - Issues a shell command in the target emulator/device 
                         instance and then exits the remote shell.

So I was wondering whether there would be some way around that, so that my shell would remain running and I could use the sqlite3 command-line program. With a bit of help from here I was able to create scripts that run specific database queries, like so (but I'd like to keep the sqlite command-line program running):

#!/bin/bash
adb shell sqlite3 /data/data/my.package.name/databases/mydatabse.db "select * from someTable"

Thanks in advance!

Community
  • 1
  • 1
Tõnis Pool
  • 185
  • 1
  • 3
  • 8
  • Share a little bit about what shell/s are available on android. Are you using bash or ?? or something specific to android? Although there are 1.2K followers for shell, probably 1/2 or them are Windows users. If there is a specific name for the android shell, better to include it. Hover on each of your tags to see the numbers of followers. 12 followers seems to be a waste of a tag. Good luck. – shellter Nov 28 '11 at 00:49

2 Answers2

1

You could try adding quotes around your adb commands, like mentioned here.

adb shell "sqlite /data/data/my.package.name/databases/mydatabse.db"

Make sure you have permission to access your database (read/write).

There is a github code published for dumping dbs, from here. Direct link: https://github.com/Pixplicity/humpty-dumpty-android/blob/master/humpty.sh

0

How about just using the command adb shell

Then run: sqlite /data/data/my.package.name/databases/mydatabse.db

This will keep the window open and then you just need to push up to get the last command.

mmontalvo
  • 83
  • 10