Created
November 24, 2019 22:46
-
-
Save mantisbayne/cd0e62e845f738187ac078e92cb97cbc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = ExampleEntity::class, version = 1, exportSchema = false) | |
@TypeConverters(Converters::class) | |
abstract class AppDatabase : RoomDatabase() { | |
abstract fun exampleDao(): ExampleDao | |
companion object { | |
// For Singleton instantiation | |
@Volatile private var instance: AppDatabase? = null | |
fun getInstance(context: Context): AppDatabase { | |
return instance ?: synchronized(this) { | |
instance ?: buildDatabase(context).also { instance = it } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment