本文整理汇总了Scala中android.database.sqlite.SQLiteDatabase类的典型用法代码示例。如果您正苦于以下问题:Scala SQLiteDatabase类的具体用法?Scala SQLiteDatabase怎么用?Scala SQLiteDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQLiteDatabase类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: SlickDatabaseHelper
//设置package包名称以及导入依赖的类
package com.nullpointerbay.dbtest
import android.content.Context
import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper}
import com.fortysevendeg.mvessel.AndroidDriver
import slick.driver.SQLiteDriver.api._
import SlickDatabaseHelper._
class SlickDatabaseHelper(context: Context)
extends SQLiteOpenHelper(context, databaseName, null, databaseVersion)
with SlickDatabaseConfig {
val driverName = "com.fortysevendeg.mvessel.AndroidDriver"
lazy val database = {
val sqliteDatabase = getReadableDatabase
AndroidDriver.register()
Database.forURL(
url = "jdbc:sqlite:" + sqliteDatabase.getPath,
driver = driverName)
}
override def onCreate(sqliteDatabase: SQLiteDatabase): Unit = {
todoTable.schema.create.statements foreach sqliteDatabase.execSQL
}
override def onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int): Unit =
throw new IllegalStateException("Can't make an upgrade")
}
object SlickDatabaseHelper {
val databaseName = "slick.db"
val databaseVersion = 1
}
开发者ID:charafau,项目名称:DbTest,代码行数:39,代码来源:SlickDatabaseHelper.scala
示例2: DBHelper
//设置package包名称以及导入依赖的类
package com.rainm.scanote.db
import android.content.Context
import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper}
import com.rainm.scanote.model.SimpleNote
object DBHelper {
val DB_VERSION = 0x1
var DB_NAME = "action_note_db"
def setDbName(dbName: String): Unit = {
DB_NAME = dbName
}
}
class DBHelper(context: Context)
extends SQLiteOpenHelper(context, DBHelper.DB_NAME, null, DBHelper.DB_VERSION) {
override def onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int): Unit = {
//TODO: add upgrade code here.
}
override def onCreate(db: SQLiteDatabase): Unit = {
db.execSQL("CREATE TABLE IF NOT EXISTS " + SimpleNote.TABLE_NAME + SimpleNote.DDL)
}
}
开发者ID:hackeris,项目名称:ScaNote,代码行数:28,代码来源:DBHelper.scala
注:本文中的android.database.sqlite.SQLiteDatabase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论