Adams Bros Blog


Upgrade Android SQLite Database

Posted by Trenton

After fiddling with a few different styles of coding a database upgrade implementation for Android, I've settled on a fairly simple method.  Basically, I take the old version, and increment a counter until I get to the current version.  Through each iteration, I use switch on the value of the upgradeTo variable, and upgrade each cycle.  If things get too complex for your application, you can always create individual upgrade methods, for each version.

Of course this method will only work if your database version is incremented by one each time you change the database.  And, this really should be the way you version it anyhow.

    public void onUpgrade(
        final SQLiteDatabase db, final int oldVersion,
        final int newVersion)
        int upgradeTo = oldVersion + 1;
        while (upgradeTo <= newVersion)
            switch (upgradeTo)
                case 5:
                case 6:
                case 7:

Someone asked in a comment, why we do the upgrade in a loop.  I do this because I do not know what version they will be converted from or to. So, I must either put a bunch of logic for every possible upgrade variation, such as 1 => 2, 1 => 3, 1=> 4, 3=> 4, etc, etc, or, I can loop through and do one upgrade at a time, and increment the version through each loop.  This GREATLY simplifies the database upgrade.

Filed under: Android, Java 19 Comments

Send Email in your Android Application

Posted by Trenton

I've seen a lot of examples of how to send email from an android application.  All of them result in applications coming up in a chooser list that are not appropriate for sending email.  In this post, I'll described the various solutions I found, and the solution that brings up only email clients.

Filed under: Android, Java Continue reading

Conversion to Dalvik format failed with error

Posted by Trenton

I went looking, and looking, and looking, for a solution to this problem. None of them seemed to fit the bill. I tried...

  1. updating proguard
  2. not using libraries I shouldn't be
  3. re-importing the project
  4. removing duplicate android jars
  5. removing all android jars
  6. a host of other "suggestions" from Eclipse Android users
Filed under: Android, Java Continue reading

Eclipse Android Hello World Tutorial Video – Part 3

Posted by Trenton

In third part of the android hello world video, we explain the different components of the application, and why things are done in a certain way.  This video is a bit raw.  However, rather than editing the videos, I'm going to try and improve my presentation skills as I go.


Eclipse Android Hello World Tutorial Video – Part 2

Posted by Trenton

Part 3 - Code Explained

Okay, I've finished another android development demo video.  Sorry it took so long, I got really busy with a new computer and what not, and life in general.  In the next video in this series, I will explain the details of the hello android application.  So, if you do not understand some of what is happening, stay tuned for the next video in the series.


Eclipse Android Hello World Tutorial Video – Part 1

Posted by Trenton

Part 2

My intention is to make all of my android videos as simple as possible, and as short as possible. That way you can learn what you need to, and get on with it.

This is a quick demo on how to get started on developing for Android.  It is "hopefully" the first in a serious of android demo videos that I will be creating.  I am mainly creating them for myself, so as to become familiar with basic android development tasks, and also to play with recording sessions; I too am a newbie to Android development.  I am putting them on YouTube in case anyone else may find them valuable; perhaps for their simplicity.  I hope you enjoy.