Created
December 4, 2019 15:01
-
-
Save 0phelia/1fe6e794017bd90fdd84ad90060cca68 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
// add to app build file | |
kapt { | |
arguments { | |
arg("room.schemaLocation", "$projectDir/schemas".toString()) | |
} | |
} | |
// set expostSchema to true# | |
...exportSchema = true | |
// copypaste new scheme and add to migration variable | |
val MIGRATION_1_2: Migration = object : Migration(1, 2) { | |
override fun migrate(database: SupportSQLiteDatabase) { | |
database.execSQL("CREATE TABLE IF NOT EXIS..........") | |
} | |
} | |
// provide migatin variable to DB | |
fun getInstance(context: Context): AppDb? { | |
if (sInstance == null) { | |
synchronized(LOCK) { | |
sInstance = Room.databaseBuilder( | |
context.applicationContext, | |
AppDb::class.java, DbConfig.DB_NAME | |
) | |
.addMigrations(MIGRATION_1_2) | |
.build() | |
} | |
} | |
return sInstance | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment