Last active
September 14, 2018 22:33
-
-
Save PauloLinhares09/f4a6d72c1425281c9cc640d45d618b27 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 = arrayOf(Team::class, Player::class), version = 1) | |
abstract class AppDatabase : RoomDatabase() { | |
abstract fun teamDao() : TeamDao | |
abstract fun playerDao() : PlayerDao | |
companion object { | |
var INSTANCE : AppDatabase? = null | |
fun getDatabaseBuilder(context: Context) : AppDatabase{ | |
if (INSTANCE == null) { | |
INSTANCE = Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, "database_app") | |
.allowMainThreadQueries() | |
.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