When I was developing my Android app Call Me Not, I struggled a bit trying to figure out how to use the ADB Android provides with it's SDK. The developer guide has a pretty good page on all the different features, however I was really confused on how to even get started. It seemed like the page was geared towards Linux users. This may be useless to many people however I myself had a hard time getting started with ADB so I'll give a quick guide how to access your sqlite3 database for your emulator using ADB in Windows. Ok so first of all, the ADB is in the android-sdk-windowsplatform-tools folder, that or you could just search for "ADB" and the executable will show up. However don't be like me I think that adb.exe is a GUI, it can only be accessed through the CMD.
1. Open up cmd.exe
2. Goto the 'android-sdk-windowsplatform-tools' directory, if your not familiar with cmd.exe, "dir" lists all files and directories, and "cd" goes into that directory.
3. You should see adb.exe if you enter in the "dir" command after navigating to the 'platform-tools' folder The only way you can use adb.exe is if an instance of an Android emulator is running. In order to determine this enter in the command "adb.exe devices" in the cmd. See picture below
If you don't see any devices listed this means that your emulator is not running and you won't be able to use adb.
4. In order to access the sqlite3 database for your emulator you need to enter the adb shell. To do this you need to add the "-s" option along with the emulator name and the "shell" option. For example see below:
the emulator name will be the one listed from the "adb.exe devices" command. You should see the cursor now next to the "#" sign.
5. Once your in the shell you need to use the sqlite3 command to access the sqlite3 database, it takes one argument, the path of the database. The path will have the format: /data/data/<your package name>/databases/<your database name> <your package name>: this is just the package name for your Android app <your database name>: assuming your using SQLiteOpenHelper this is the database name you use for the constructor, ex "items.db" See below for an example:
6. Now that your in the database, you can start issuing commands to see what's in your tables. Commands I use: .schema - shows all the different tables and their schema structure .tables - lists all tables in the database From there you can just issue SQL commands like "select * from prices;" and it'll list all the rows in that table. See picture below for an example:
I hope this helps anyone that's not sure how to use the ADB in the Android SDK for Windows.
Comments