Last active
November 27, 2018 09:21
-
-
Save shkschneider/4626a2a7a7812c309eb356ccc165978b 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 = [ | |
User::class, | |
Project::class, | |
Notification::class | |
], version = 1, exportSchema = false) | |
abstract class MyDatabase : RoomDatabase() { | |
abstract fun users(): Users | |
abstract fun projects(): Projects | |
abstract fun notifications(): Notifications | |
companion object { | |
private var INSTANCE: MyDatabase? = null | |
fun get(context: Context): MyDatabase { | |
if (INSTANCE == null) { | |
INSTANCE = Room.inMemoryDatabaseBuilder(context.applicationContext, MyDatabase::class.java) | |
.allowMainThreadQueries() // FIXME never do this (coroutines to come) | |
.build() | |
} | |
return INSTANCE!! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment