WiP, drawer works now

This commit is contained in:
Max Lv
2013-09-22 10:52:44 +08:00
parent ae2319ca04
commit 53fcba30b0
10 changed files with 120 additions and 24 deletions
@@ -0,0 +1,22 @@
package com.github.shadowsocks.database
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import com.j256.ormlite.support.ConnectionSource
import com.j256.ormlite.table.TableUtils
import com.j256.ormlite.dao.Dao
class DBHelper(implicit val context: Context) extends OrmLiteSqliteOpenHelper(context, "postnauka", null, 3) {
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) {
TableUtils.dropTable(connectionSource, classOf[Profile], true)
onCreate(database, connectionSource)
}
}
@@ -0,0 +1,47 @@
package com.github.shadowsocks.database
import com.j256.ormlite.field.{DataType, DatabaseField}
class Profile {
@DatabaseField(id = true)
var id: Int = 0
@DatabaseField
var name: String = null
@DatabaseField(foreign = true, canBeNull = false)
var host: String = null
@DatabaseField
var localPort: Int = 0
@DatabaseField
var remotePort: Int = 0
@DatabaseField
var password: String = null
@DatabaseField
var method: String = null
@DatabaseField
var date: String = null
@DatabaseField
var upload: Int = 0
@DatabaseField
var download: Int = 0
@DatabaseField
var chnroute: Boolean = false
@DatabaseField
var global: Boolean = false
@DatabaseField(dataType = DataType.LONG_STRING)
var individual: String = null
@DatabaseField(dataType = DataType.LONG_STRING)
var description: String = null
}