From cbd5de6c481574d84241efbe5a7226faa72414ba Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 9 Mar 2020 21:37:51 +0100 Subject: [PATCH] adding a new column for storing the app icons order --- .../simplemobiletools/applauncher/helpers/DBHelper.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt index b9da862..228ea53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt @@ -23,11 +23,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont private val COL_PKG_NAME = "package_name" private val COL_POSITION = "position" private val COL_WAS_RENAMED = "was_renamed" + private val COL_APP_ORDER = "app_order" private val mDb = writableDatabase companion object { - private const val DB_VERSION = 5 + private const val DB_VERSION = 6 val DB_NAME = "applaunchers.db" var dbInstance: DBHelper? = null @@ -42,7 +43,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont override fun onCreate(db: SQLiteDatabase) { db.execSQL("CREATE TABLE $MAIN_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_NAME TEXT, $COL_PKG_NAME TEXT UNIQUE, $COL_POSITION INTEGER," + - "$COL_WAS_RENAMED INTEGER)") + "$COL_WAS_RENAMED INTEGER, $COL_APP_ORDER INTEGER)") addInitialLaunchers(db) } @@ -60,6 +61,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont if (oldVersion < 5) { db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_WAS_RENAMED INTEGER NOT NULL DEFAULT 0") } + + if (oldVersion < 6) { + db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_APP_ORDER INTEGER NOT NULL DEFAULT 0") + } } private fun addInitialLaunchers(db: SQLiteDatabase) {