renaming the database variable

This commit is contained in:
tibbi 2018-05-13 23:02:31 +02:00
parent 06e03a0f5c
commit 6e898e43b8

View file

@ -17,21 +17,21 @@ abstract class GalleryDataBase : RoomDatabase() {
abstract fun MediumDao(): MediumDao
companion object {
private var INSTANCE: GalleryDataBase? = null
private var db: GalleryDataBase? = null
fun getInstance(context: Context): GalleryDataBase {
if (INSTANCE == null) {
if (db == null) {
synchronized(GalleryDataBase::class) {
INSTANCE = Room.databaseBuilder(context.applicationContext, GalleryDataBase::class.java, "gallery.db")
db = Room.databaseBuilder(context.applicationContext, GalleryDataBase::class.java, "gallery.db")
.fallbackToDestructiveMigration()
.build()
}
}
return INSTANCE!!
return db!!
}
fun destroyInstance() {
INSTANCE = null
db = null
}
}
}