Android development is just beginning

Yesterday I spent a few hours trying to develop a minimalistic application for my new android phone. With the help of a quick Hello World tutorial I got up and running quite quickly. Within a few minutes I had Hello World showing up in the Android phone emulator.

When I tried to start it on my real device, I had the problem, that my phone was not showing up as connected device when I plugged it in via USB but only its internal memory was available as drive. After some investigation and research I found out, that I plugged in my phone before I activated the USB debugging mode on the phone which causes some driver irritation on Windows. This thread explains the details and how to solve the issue.

The next thing I did was to find out how to load the contacts stored on my SIM card. This is not a very well documented task so here is the required code to use Content Providers for loading contacts from the SIM module. This method returns the contacts as ArrayList of Strings which consist of the three fields name, number and _id.

private ArrayList<String> retrieveSIMContacts() {
    Uri uri15 = Uri.parse("content://sim/adn/");

    ContentResolver resolver = getContentResolver();
    Cursor results = resolver.query(uri15, null, null, null, null);

    // Android 1.6 has a different URI
    if(null == results) {
        Uri uri16 = Uri.parse("content://icc/adn/");
        results = resolver.query(uri16, null, null, null, null);

    final ArrayList<String> simContacts = new ArrayList<String>();
    final int nameIndex = results.getColumnIndex("name");
    final int numberIndex = results.getColumnIndex("number");
    final int idIndex = results.getColumnIndex("_id");

    while (results.moveToNext()) {
        final StringBuilder builder = new StringBuilder();
        builder.append(results.getString(nameIndex)).append(" : ");
        builder.append(results.getString(numberIndex)).append(" : ");

    return simContacts;

All in all I got a small app running on my real phone showing the contacts from both the phone itself and the SIM card in two listviews selectable via tabs within two or three hours.

Quite fast, I'm impressed. I expected that Android development would be a bit more complicated...

Update 2010-01-04: Update for Android 1.6


Similar entries