Posts

Showing posts from June, 2010

Examining Android database tables using an adb shell and sqlite3

Image
In this post we see how easy it is to use an ADB shell and sqlite3 to examine the contents of a SQLite database on an Android device. I will be using the Android Notepad tutorial as an example. To start build and run the Notepad tutorial using the emulator. I am using the Notepad V4 version I created by upgrading the NotepadV3solution, as this removes a couple of annoying bugs. Instructions on how to build this are given in the previous post. While the application is running on the emulator, create a number of notes with known contents. I created 4 notes with titles of 1, 2, 3 and 4 and bodies of “Body 1”, “Body 2” etc… Now on a windows command line open a shell on the emulator using the ADB command Adb –e shell You will get a # prompt, showing that you are now running a linux shell on the emulator. Android stores SQLite databases in /data/data/{application package name}/databases. So we need to navigate to this directory. I do this in a few steps. (1) cd data/data (2) ls (3) cd my.and...

Using Log.v, LogCat and Filters when debugging an Android Application

Image
When debugging an Android Application one of the most useful tools is Log.v. This is a means of sending debug messages to the log file, which can be read in real-time with LogCat. I will illustrate this using a real bug in the Android Notepad tutorial. If you have been following this blog you will now have a version of Notepad (NotepadV4) that makes it easy to add edit and delete Notes. If you run it in the emulator, chose the DDMS perspective in Java and select the emulator then you will see LogCat showing the log messages from Android. Try editing a number of notes within the Notepad application. After editing 4 the following error messages appeared in LogCat. I have maxmised the LogCat Window as the error messages are quite long. The crucial error messages are: 06-07 14:54:31.530: ERROR/Database(221): java.lang.IllegalStateException: /data/data/my.android.demo.notepad4/databases/data SQLiteDatabase created and never closed and 06-07 14:54:31.530: ERROR/Database(221): at my.andr...

Extending the Android Notepad tutorial (Notepad v4)

Image
In order to develop my understanding of Android and the Notepad tutorial I decided to extend it, and correct some bugs. I first created a copy of the Notepad3solution tutorial directory named NotepadV4 and created an Eclipse Project called NotepadV4 from this source code. The detailed steps to accomplish this within Eclipse were given in my previous post. Once you have the project up on running on the emulator it will look like this. The first change is to correct the application name shown in the ListView. Changing the application name is easy using the XML editor provided within the ADT Eclipse plugin. Simply update the app_name string within strings.xml using the editors resources tab as shown below. The next change is to improve the No Notes! message. Due to a minor bug within Notepad3solution, this is currently defined within notes_list.xml in the following: textview id="@+id/android:empty" layout_width="wrap_content" layout_height="wrap_content" text...