List of usage examples for android.database.sqlite SQLiteOpenHelper SQLiteOpenHelper
public SQLiteOpenHelper(@Nullable Context context, @Nullable String name, int version, @NonNull SQLiteDatabase.OpenParams openParams)
From source file:com.google.android.apps.forscience.whistlepunk.sensordb.SensorDatabaseImpl.java
public SensorDatabaseImpl(Context context, String name) { mOpenHelper = new SQLiteOpenHelper(context, name, null, DbVersions.CURRENT) { @Override/*from w w w . j a va2s.c om*/ public void onCreate(SQLiteDatabase db) { db.execSQL(ScalarSensorsTable.CREATION_SQL); db.execSQL(ScalarSensorsTable.INDEX_SQL); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { while (oldVersion != newVersion) { if (oldVersion == DbVersions.V1_START) { db.execSQL(ScalarSensorsTable.INDEX_SQL); oldVersion = DbVersions.V2_INDEX; } else if (oldVersion == DbVersions.V2_INDEX) { db.execSQL("ALTER TABLE " + ScalarSensorsTable.NAME + " ADD COLUMN " + ScalarSensorsTable.Column.RESOLUTION_TIER + " INTEGER DEFAULT 0;"); oldVersion = DbVersions.V3_TIER; } } } }; }