Created
September 14, 2018 15:30
-
-
Save CoderJava/abe2ca4eda06a9e20d33ce811de2e5d2 to your computer and use it in GitHub Desktop.
Waktu database
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 = [(WaktuData::class)], version = 1) | |
| abstract class WaktuDb : RoomDatabase() { | |
| abstract fun waktuDao(): WaktuDao | |
| companion object { | |
| private var INSTANCE: WaktuDb? = null | |
| fun getInstance(context: Context) : WaktuDb? { | |
| if (INSTANCE == null) { | |
| synchronized(WaktuDb::class) { | |
| INSTANCE = Room.databaseBuilder(context.applicationContext, WaktuDb::class.java, "waktu.db") | |
| .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