WiP, drawer works now
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user