If you think the Android project android-sqlite-helper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package net.ichigotake.sqlitehelper;
/*fromwww.java2s.com*/import android.database.sqlite.SQLiteDatabase;
import net.ichigotake.sqlitehelper.ddl.AlterTable;
import net.ichigotake.sqlitehelper.ddl.CreateIndex;
import net.ichigotake.sqlitehelper.ddl.CreateTable;
import net.ichigotake.sqlitehelper.schema.Table;
publicclass MigrationHelper {
publicstaticvoid onCreate(SQLiteDatabase db, Configuration configuration) {
for (Table table : configuration.getDatabaseTables()) {
new CreateTable(db, table.getTableSchema()).createTableIfNotExists();
}
configuration.getMigrationCallback().onAfterCreate(db);
}
publicstaticvoid onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion, Configuration configuration) {
for (Table table : configuration.getDatabaseTables()) {
if (oldVersion <= table.getSenseVersion() && table.getSenseVersion() <= newVersion) {
new CreateTable(db, table.getTableSchema()).createTableIfNotExists();
}
new CreateIndex(db, table.getTableSchema()).createIndexIfNotExists();
new AlterTable(db, table).addColumn();
}
configuration.getMigrationCallback().onAfterUpgrade(db, oldVersion, newVersion);
}
private MigrationHelper() {}
}