Tuesday, August 28, 2012

Android: can't upgrade read-only database from version 0 to 1


If you have named one of your SQLite tables "default", change the name to something else.


So I was poking around with Android programming the other day, and I ran into this error:

04-12 14:35:09.779: ERROR/AndroidRuntime(790): Caused by: android.database.sqlite.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.example.test/databases/mydatabase.db
04-12 14:35:09.779: ERROR/AndroidRuntime(790): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:170)

The line causing the error was simply calling SQLiteOpenHelper.getReadableDatabase():

SQLiteDatabase db = dbHelper.getReadableDatabase();

I finally narrowed it down to the database table name I was using: "default". As soon as I changed the table name, it worked fine. In fact, I simply changed it from "default" to "default1".

Just to be clear, I wasn't doing anything fancy. I was using pretty basic code to create the database:

public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DB_TABLE_NAME = "default";
    public static final String DB_TABLE_CREATE =

It doesn't appear to be a SQLite thing, because according to their documentation the only reserved table names begin with "sqlite_". So it appears to be an Android issue, and as far as I can tell it isn't documented.

I checked the database after I changed the name, and the "default" table was never created either, so I'm not sure why it wouldn't work:

sqlite> .tables
android_metadata default1

A bug, perhaps?

Thursday, August 23, 2012

GO Launcher EX: a great LauncherPro replacement

I've been using LauncherPro for my android launcher/home screen for a while. I was quite happy with it at first, but I've been gradually growing less pleased with it:
  • It hangs/crashes every time my phone first boots up

  • If I accidentally long press on one of my widgets, I get an annoying nag screen to buy the pro version

  • Over a year ago, it stopped showing my unread gmail count
Why have I still been using LauncherPro then? it has a really cool scrollable dock that allows me to put multiple rows of my most used shortcuts.

Well, byebye launcherpro. I just stumbled across GO Launcher EX, and:

Wednesday, August 22, 2012

Fix Half Life 2 lighting issues


  • You need to be using a video card that supports DirectX 9 and the DirectX level in Half Life 2 needs to be 90 or higher. In the console, type mat_dxlevel to see the directx level. To set it to 90, for example, type mat_dxlevel 90

  • HDR needs to be fully enabled. The easiest way to do this (after correctly setting the directx level) is by typing this in the console: mat_hdr_level 2 and then type mat_hdr_enabled to make sure HDR is in fact enabled.

  • Lastly, if the lighting is still messed up, type mat_fullbright 0 in the console to fix it.

  • An alternative is to download these files:

    Open them to extract the files (in Linux, you can open them using Wine). Then copy the files to SteamApps/common/Half-Life 2/hl2/maps in your Steam installation folder (~/.local/share/Steam on Linux, or in C:/Program Files on Windows).


I was recently playing Half Life 2 on Linux using Wine, and at one point, all the lighting messed up. It basically looked like there were no shadows at all. The screenshot above is supposed to be in a dark tunnel.

Supposedly this was caused by an update to the Half Life 2 maps when the orange box was released. Somehow or another, some of the maps require HDR to be enabled for the lighting to work. HDR is only supported in DirectX 9 and higher, and I was setting the DirectX level to 80 (DirectX 8.0) by using the -dxlevel 80 flag in the launch options. I had to remove that flag, and then take the steps above to fix the problem.

Once I did fix the lighting, the game got significantly slower. Still playable, but a lot more annoying to play. Using some of my tips on playing Half Life 2 on an older computer helped, but some of the textures are messed up.  This may affect other source games as well.

Now that Half Life 2 is playable natively on Linux, this is issue will probably only affect Windows users.

Wednesday, August 15, 2012

Cross-platform mobile development: PhoneGap + Enyo

If you want to develop a mobile application, but don't want to have to rewrite it for every platform you want to develop for (Android, iOS, etc.), PhoneGap is what you want. It allows you to develop applications using web technologies (HTML, CSS, JavaScript), and then deploy them to a large number of platforms, such as Android and iOS. It has APIs that let you interface directly with the mobile device's hardware (camera, GPS, accelerometer, you name it). It's even been approved by Apple, and we all know what a feat that is ;)

Undoubtedly you'll want a nice framework that gives you all the UI widgets you're used to: layouts, spinners, popups, progress bars, etc. That's where Enyo comes in. Enyo was actually the JavaScript framework that was part of WebOS. Since WebOS has been open-sourced, so has Enyo. I would recommend Enyo over other JavaScript frameworks like jQuery Mobile and Sencha; see here for some reasons why: Enyo+PhoneGap Vs jQueryMobile+PhoneGap

There are already some apps out there using this approach. Here are a couple for android:
I've even done some playing around with phonegap and the enyo samples myself. I put it in github in case it's of any interest:

The screenshots in this post are from that code, and you can see more here: