Skip to content

Android Database Programming: FAQ

Hey everyone! This page will be dedicated to those who have read my new book, Android Database Programming, and have any questions. Feel free to post your questions and I’ll do my best to get back to you within a day or two.

As the questions come, my goal is to slowly aggregate and incorporate them into the page itself, with the end goal of turning this page into a FAQ. Thanks and let the questions come!

6 Comments leave one →
  1. 'Dev22' permalink
    July 16, 2012 8:50 am


    Thanks for the blog page and for the projects. I have read through most of the material in your Android Database Programming book. I have found parts of it to be quite helpful. However, what I need to do is use an existing (pre-populated) SQLite database (that would be along included with the app) and I have not found instructions for this in the book. This was actually one of the main reasons I purchased this book. Could you advise how to connect to & query a local (pre-populated) SQLite dbase?

    Also, I have downloaded and tried sample projects, but I get errors when I try to open some of them on the emulator. I would particularly be interested in the project for Chapter 6, but I cannot get this to run on the emulator.

    Thanks in advance for your help.

    • July 17, 2012 10:03 am

      Hi Dev,

      I’m not sure what you problems you’re having with querying an existing SQLite database. For instance, if the SQLite database belongs to a different application, then it needs to be exposed with a ContentProvider and Ch4 and Ch5 will tell you how to both expose a SQLite database as well as query it.

      Otherwise, if it’s a SQLite database that the application owns, Ch3 teaches you about issuing queries to those databases.

      Why don’t you email me at at and we’ll try and hash out the issue.

      – jwei

  2. Robert A. Vasseur permalink
    November 23, 2012 10:43 am

    I’m an experienced programming/database guy, but am having a great deal of difficulty dealing with Android database programming (not that it’s the only Android area where I am experiencing problems). So, I got your book and downloaded the example projects from Packt into Eclipse, and am using the default emulator in Windows 7.

    When I try to run a specific activity in the project using a run configuration, it always shows up on the emulator as the SharedPreferences activity, and all the multitude of icons that show up on the screen (15 of them) have the same label, “DataForAndroidExamples”. Since I can find no instructions on how to configure Eclipse to get the right activity to run in your examples, it is driving me to distraction.

    Any words of wisdom?

    • November 24, 2012 11:06 am

      Hi Robert,

      I believe you should have been able to download the source code for all of the examples – everything from the Activities to the Android Manifest files, etc.

      If that’s the case (and if it’s not then let me know as you should be able to) then you can simply go into the Android Manifest file and change which Activity is the intent.action.MAIN Activity.

      For instance, the Manifest file could look like:

              <!-- [Chapter 1 Storing Data on Android] Activity Declarations -->
              <activity android:name=".ch1.SQLiteExample" android:label="@string/app_name">
                      <action android:name="android.intent.action.MAIN" />
                      <category android:name="android.intent.category.LAUNCHER" />
          	<activity android:name=".ch1.InternalStorageExample2" android:label="@string/app_name">
                      <category android:name="android.intent.category.LAUNCHER" />
              <activity android:name=".ch1.SharedPreferencesExample" android:label="@string/app_name">
                      <category android:name="android.intent.category.LAUNCHER" />

      So here when you compile and launch the application, it will then bring you to the SQLiteExample Activity.

      Sorry for the confusion – it’s just that when I was writing the book at some point all of these Activities were the “main” ones and needed to get launched.

      Hope this solves the problem – let me know if you have any more issues.

      – jwei

  3. November 24, 2012 2:14 pm

    Here is a snippet of the code in the manifest that comes when you download the examples:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: