@Database(
entities = [WeekDays::class],
version = 1
) 抽象类 AppDatabase : RoomDatabase() { 抽象乐趣 raspisanyDao(): RaspisanyDao
companion object {
@Volatile
private var myRoomInstance: AppDatabase? = null
internal fun getDatabase(context: Context): AppDatabase? {
if (myRoomInstance == null) {
synchronized(AppDatabase::class.java) {
if (myRoomInstance == null) {
myRoomInstance = Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java, "app_db"
).build()
}
}
}
return myRoomInstance
}
}
}