Created
April 1, 2019 00:30
-
-
Save enginebai/b9b3af8d0df557da87516de905fd67bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Database(entities = [NewPost::class], version = 1) | |
abstract class NewPostDatabase: RoomDatabase() { | |
abstract fun newPostDao(): NewPostDao | |
companion object { | |
private var INSTANCE: NewPostDatabase? = null | |
fun getInstance(context: Context): NewPostDatabase? { | |
if (INSTANCE == null) { | |
synchronized(NewPostDatabase::class) { | |
INSTANCE = Room.databaseBuilder(context, | |
NewPostDatabase::class.java, | |
NewPostDatabase::class.java.simpleName).build() | |
} | |
} | |
return INSTANCE | |
} | |
fun destroyInstance() { | |
INSTANCE = null | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment