Android, OnCreate and Why Doesn’t my DB Exist?

This is probably one of the more embarrassing bugs I will ever post on my blog.

Due to the way I laid out an Android app, I had two different tables that were in two different DB adapters.

Unfortunately, for the life of me, I couldn’t understand why the OnCreate function in a SQLiteOpenHelper-inherited class was not running for one of the two.

So it turns out, OnCreate is only fired when you CREATE a db. Since I was trying to share one DB between two tables, I wound up creating the database just fine – with only half the tables. (I thought OnCreate dealt with tables through some kind of background magic).

I split the DBs, but in all honesty, the best move to do is further abstract the DB creation aspects so that the tables stay in the same place…