Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created June 16, 2024 15:57
Show Gist options
  • Save sajjadyousefnia/657054579899cc6f3afcff90eebb3442 to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/657054579899cc6f3afcff90eebb3442 to your computer and use it in GitHub Desktop.
@Database(
entities = [MdlMovie::class, MdlLastPlay::class],
version = 16, exportSchema = false
)
@TypeConverters(Converters::class)
abstract class RoomDB : RoomDatabase() {
abstract fun appDao(): AppDao
companion object {
private var INSTANCE: RoomDB? = null
fun getDatabase(context: Context): RoomDB {
if (INSTANCE == null) {
synchronized(RoomDB::class.java) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.applicationContext, RoomDB::class.java, "sands_db")
.fallbackToDestructiveMigration()
//.addTypeConverter(converterFactory)
.allowMainThreadQueries()
.build()
}
}
}
return INSTANCE!!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment