fix the database issue
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user