From e6049432950d4ce6aef10961f297f98baa1d43dc Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 27 Apr 2018 21:42:17 +0200 Subject: [PATCH] update the database, add app_icon_color column --- app/build.gradle | 2 +- .../thankyou/dbhelpers/MyContentProviderDbHelper.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 22d4092..05b39c9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:3.19.24' + implementation 'com.simplemobiletools:commons:3.19.25' } Properties props = new Properties() diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt index 9cf1c91..b8d63ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt @@ -20,7 +20,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context companion object { private const val DB_NAME = "Commons.db" - private const val DB_VERSION = 1 + private const val DB_VERSION = 2 private const val TABLE_NAME = "commons_colors" private const val THEME_ID = 1 // for now we are storing just 1 theme @@ -29,10 +29,14 @@ class MyContentProviderDbHelper private constructor(private val context: Context override fun onCreate(db: SQLiteDatabase) { db.execSQL("CREATE TABLE $TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_TEXT_COLOR INTEGER DEFAULT 0, $COL_BACKGROUND_COLOR INTEGER DEFAULT 0," + - " $COL_PRIMARY_COLOR INTEGER DEFAULT 0, $COL_LAST_UPDATED_TS INTEGER DEFAULT 0)") + " $COL_PRIMARY_COLOR INTEGER DEFAULT 0, $COL_APP_ICON_COLOR INTEGER DEFAULT 0, $COL_LAST_UPDATED_TS INTEGER DEFAULT 0)") } - override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {} + override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + if (oldVersion == 1) { + db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_APP_ICON_COLOR INTEGER DEFAULT 0") + } + } private fun insertDefaultTheme() { val resources = context.resources