Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Context
- import androidx.room.Room
- import androidx.room.RoomDatabase
- abstract class ExampleDB : RoomDatabase() {
- companion object {
- private var INSTANCE: ExampleDB? = null
- @JvmStatic
- fun get(context : Context): ExampleDB {
- if (INSTANCE == null) {
- INSTANCE =
- Room.databaseBuilder(context, ExampleDB::class.java, "example.db").build()
- }
- return INSTANCE!!
- }
- @JvmStatic
- fun destroyInstance() {
- INSTANCE = null
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement