outsource resetting of positions table

storage_ts_index
Georg Lukas 2011-02-05 14:34:09 +01:00
rodzic 5047ea7df4
commit a50e18d987
1 zmienionych plików z 19 dodań i 14 usunięć

Wyświetl plik

@ -91,11 +91,7 @@ class StorageDatabase(context : Context) extends
db.execSQL(Position.TABLE_CREATE)
Array("call", "lat", "lon").map(col => db.execSQL(Position.TABLE_INDEX.format(col, col)))
}
override def onUpgrade(db: SQLiteDatabase, from : Int, to : Int) {
if (from == 1 && to >= 2) {
db.execSQL("ALTER TABLE %s ADD COLUMN %s".format(Post.TABLE, "TYPE INTEGER DEFAULT 0"))
}
if (from <= 4 && to >= 3) {
def resetPositionsTable(db : SQLiteDatabase) {
db.execSQL(Position.TABLE_DROP)
db.execSQL(Position.TABLE_CREATE)
Array("call", "lat", "lon").map(col => db.execSQL(Position.TABLE_INDEX.format(col, col)))
@ -111,6 +107,15 @@ class StorageDatabase(context : Context) extends
}
c.close()
}
def resetPositionsTable() : Unit = resetPositionsTable(getWritableDatabase())
override def onUpgrade(db: SQLiteDatabase, from : Int, to : Int) {
if (from == 1 && to >= 2) {
db.execSQL("ALTER TABLE %s ADD COLUMN %s".format(Post.TABLE, "TYPE INTEGER DEFAULT 0"))
}
if (from <= 4 && to >= 3) {
resetPositionsTable(db)
}
}
def trimPosts(ts : Long) {