Given that I did not find anything that supported Android, it actually worked, didn’t require me to sign up for a crazy world view of the database and not cost a lot (hobby project, no blocks), I came up with the following hack. This is not smart, but at least it allows me to think about my circuits the way I know. I do not expect this to work well for a large code / database scheme, but if you have this, you can probably afford to pay for something.
public class AppDatabase extends SQLiteOpenHelper { public static final String DATABASE_NAME = "main"; public static final int LATEST_VERSION = 4; public static SQLiteDatabase open(Context ctx) { AppDatabase db = new AppDatabase(ctx); return db.getWritableDatabase(); } public AppDatabase(Context ctx) { super(ctx, DATABASE_NAME, null, LATEST_VERSION); } @Override public void onCreate(SQLiteDatabase db) { onUpgrade(db, 0, LATEST_VERSION); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { for (int i = oldVersion+1; i <= newVersion; i++) { switch (i) { case 1: db.execSQL("CREATE TABLE blah ( " + "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," + "start CHAR(4)," + "end CHAR(4)" + ")"); break; case 2: db.execSQL("CREATE TABLE fortnights ( " + "first_day DATE PRIMARY KEY" + ")"); break; case 3: db.execSQL("ALTER TABLE shifts ADD top CHAR(4)"); db.execSQL("ALTER TABLE shifts ADD bottom CHAR(4)"); db.execSQL("UPDATE shifts set top=start, bottom=end"); break; case 4: db.execSQL("ALTER TABLE shifts ADD callout BOOLEAN DEFAULT 0"); break; } } } }
source share