|
|
@@ -0,0 +1,29 @@
|
|
|
+package com.grkj.iscs.model
|
|
|
+
|
|
|
+import androidx.room.Database
|
|
|
+import androidx.room.Room
|
|
|
+import androidx.room.RoomDatabase
|
|
|
+import com.grkj.iscs.MyApplication
|
|
|
+
|
|
|
+/**
|
|
|
+ * 本地数据库
|
|
|
+ */
|
|
|
+@Database(version = ISCSMigrations.VERSION)
|
|
|
+abstract class ISCSDatabase : RoomDatabase() {
|
|
|
+ companion object {
|
|
|
+ /**
|
|
|
+ * 单例
|
|
|
+ */
|
|
|
+ @JvmStatic
|
|
|
+ val instance: ISCSDatabase by lazy {
|
|
|
+ Room.databaseBuilder(
|
|
|
+ MyApplication.instance?.applicationContext!!,
|
|
|
+ ISCSDatabase::class.java,
|
|
|
+ "iscs_database"
|
|
|
+ )
|
|
|
+ // 如需在主线程查询,可取消下行注释(不推荐):
|
|
|
+ // .allowMainThreadQueries()
|
|
|
+ .build()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|