Commit 9218ee42 authored by Max Lv's avatar Max Lv

fix the database issue

parent cc5fafbd
......@@ -107,7 +107,11 @@ trait BaseService {
if (state != s) {
val n = callbacks.beginBroadcast()
for (i <- 0 to n - 1) {
callbacks.getBroadcastItem(i).stateChanged(s, msg)
try {
callbacks.getBroadcastItem(i).stateChanged(s, msg)
} catch {
case _: Exception => // Ignore
}
}
callbacks.finishBroadcast()
state = s
......
......@@ -50,20 +50,24 @@ object DBHelper {
val PROFILE = "profile.db"
}
class DBHelper(val context: Context) extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 8) {
class DBHelper(val context: Context)
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 8) {
lazy val profileDao:Dao[Profile,Int] = getDao(classOf[Profile])
lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile])
def onCreate(database: SQLiteDatabase, connectionSource: ConnectionSource) {
TableUtils.createTable(connectionSource, classOf[Profile])
}
def onUpgrade(database: SQLiteDatabase, connectionSource: ConnectionSource, oldVersion: Int, newVersion: Int) {
if (oldVersion < 8) {
profileDao.executeRaw("ALTER TABLE `profile` ADD COLUMN udpdns INTEGER;")
} else {
TableUtils.dropTable(connectionSource, classOf[Profile], true)
def onUpgrade(database: SQLiteDatabase, connectionSource: ConnectionSource, oldVersion: Int,
newVersion: Int) {
if (oldVersion != newVersion) {
if (oldVersion < 8) {
profileDao.executeRaw("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;")
} else {
profileDao.executeRaw("DROP TABLE IF EXISTS 'profile';")
onCreate(database, connectionSource)
}
}
onCreate(database, connectionSource)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment