/* * Generated by Robotoworks Mechanoid */ package com.robotoworks.example.recipes.content; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import com.robotoworks.mechanoid.db.MechanoidSQLiteOpenHelper; import com.robotoworks.mechanoid.db.SQLiteMigration; import com.robotoworks.example.recipes.content.migrations.DefaultRecipesDBMigrationV1; import com.robotoworks.example.recipes.content.migrations.DefaultRecipesDBMigrationV2; import com.robotoworks.example.recipes.content.migrations.DefaultRecipesDBMigrationV3; public abstract class AbstractRecipesDBOpenHelper extends MechanoidSQLiteOpenHelper { private static final String DATABASE_NAME = "RecipesDB.db"; public static final int VERSION = 3; public interface Sources { String RECIPES = "recipes"; String AUTHORS = "authors"; String INGREDIENTS = "ingredients"; String RECIPES_WITH_AUTHORS = "recipes_with_authors"; String RECIPES_AND_INGREDIENTS = "recipes_and_ingredients"; } public AbstractRecipesDBOpenHelper(Context context) { super(context, DATABASE_NAME, null, VERSION); } public AbstractRecipesDBOpenHelper(Context context, String name) { super(context, name, null, VERSION); } @Override public void onCreate(SQLiteDatabase db) { applyMigrations(db, 0, VERSION); } @Override protected SQLiteMigration createMigration(int version) { switch(version) { case 0: return createRecipesDBMigrationV1(); case 1: return createRecipesDBMigrationV2(); case 2: return createRecipesDBMigrationV3(); default: throw new IllegalStateException("No migration for version " + version); } } protected SQLiteMigration createRecipesDBMigrationV1() { return new DefaultRecipesDBMigrationV1(); } protected SQLiteMigration createRecipesDBMigrationV2() { return new DefaultRecipesDBMigrationV2(); } protected SQLiteMigration createRecipesDBMigrationV3() { return new DefaultRecipesDBMigrationV3(); } }