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

perltwit just release

Posted by Trenton

Perl Twit is a Linux/Unix command line utility for sending twitter messages.

I've been using this for probably well over a year now, and just never managed to release it.  Today I decided to push it up to, and let the world have at her.

Filed under: Linux, Perl No 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.


Maven Test Debug Mode Profile

Posted by Trenton

I should have blogged about this long ago, as I feel that this is a very useful way of debugging unit tests with maven.  This is especially so if you're primarily a command line sort of guy like myself.

All that is required to be able to debug a unit test is

  1. configure the maven surefire plugin from within a profile
  2. activate the maven profile from the command line

The following XML profiles section will work just peachy for you.


Now just run this.

  mvn -Pdtest package
Filed under: Java No Comments

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.


Java LDAP Persistence API

Posted by Trenton

I've started a project called LDAP Persistence API for Java, or LPA for short. It is a Java framework for interacting with LDAP entries using pure Java objects. It is based on Java annotations.

It is no were near to being complete, but the query functionality is working. I still have a lot of work to do, in order to make it be able to persist existing annotated Java objects to LDAP.  I'm likely to create some sort of intermediate step, until I can finish that.


Java Array Reflection

Posted by Trenton

In this article we talk about reflection with arrays in Java. Java array reflection is not difficult, but it can be trying to figure it out without a good example. Ultimately, what I needed was a way of injecting information into an array field. Of course, you need to inject the same "type" of array as the field is. That is what can be difficult to figure out, if you've never done it before.

In this example, I am using Java 1.6. I won't bother determining what is, or is not supported in prior versions of the Java language.