Created
September 13, 2018 19:47
-
-
Save PauloLinhares09/f87de2b88554e469f30b8da5588bba60 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 MY_INSTANCE : AppDatabase? = null | |
fun createInmemoryDatabse(context : Context) : AppDatabase{ | |
if (MY_INSTANCE == null){ | |
MY_INSTANCE = Room.inMemoryDatabaseBuilder(context.applicationContext, AppDatabase::class.java) | |
.allowMainThreadQueries() | |
.build() | |
} | |
return MY_INSTANCE!! | |
} | |
fun destroyInstance(){ | |
MY_INSTANCE = null | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment