renaming the database variable
This commit is contained in:
parent
06e03a0f5c
commit
6e898e43b8
1 changed files with 5 additions and 5 deletions
|
@ -17,21 +17,21 @@ abstract class GalleryDataBase : RoomDatabase() {
|
||||||
abstract fun MediumDao(): MediumDao
|
abstract fun MediumDao(): MediumDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var INSTANCE: GalleryDataBase? = null
|
private var db: GalleryDataBase? = null
|
||||||
|
|
||||||
fun getInstance(context: Context): GalleryDataBase {
|
fun getInstance(context: Context): GalleryDataBase {
|
||||||
if (INSTANCE == null) {
|
if (db == null) {
|
||||||
synchronized(GalleryDataBase::class) {
|
synchronized(GalleryDataBase::class) {
|
||||||
INSTANCE = Room.databaseBuilder(context.applicationContext, GalleryDataBase::class.java, "gallery.db")
|
db = Room.databaseBuilder(context.applicationContext, GalleryDataBase::class.java, "gallery.db")
|
||||||
.fallbackToDestructiveMigration()
|
.fallbackToDestructiveMigration()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return INSTANCE!!
|
return db!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroyInstance() {
|
fun destroyInstance() {
|
||||||
INSTANCE = null
|
db = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue