Fix reading/writing values from/to folder_extra_values
@@ -2,6 +2,7 @@ package com.fsck.k9.mailstore
import android.content.ContentValues
import android.database.Cursor
+import android.database.sqlite.SQLiteDatabase
import androidx.core.database.getStringOrNull
import com.fsck.k9.Account
import com.fsck.k9.Preferences
@@ -245,31 +246,41 @@ class K9BackendFolder(
override fun getFolderExtraString(name: String): String? {
return database.getStringOrNull(
table = "folder_extra_values",
- column = "value_string"
+ column = "value_text",
+ selection = "name = ? AND folder_id = ?",
+ selectionArgs = *arrayOf(name, databaseId)
)
}
override fun setFolderExtraString(name: String, value: String) {
- database.setString(
- table = "folder_extra_values",
- column = "value_string",
- value = value
- )
+ database.execute(false) { db ->
+ val contentValues = ContentValues().apply {
+ put("name", name)
+ put("value_text", value)
+ put("folder_id", databaseId)
+ }
+ db.insertWithOnConflict("folder_extra_values", null, contentValues, SQLiteDatabase.CONFLICT_REPLACE)
+ }
}
override fun getFolderExtraNumber(name: String): Long? {
return database.getLongOrNull(
table = "folder_extra_values",
- column = "value_integer"
+ column = "value_integer",
+ selection = "name = ? AND folder_id = ?",
+ selectionArgs = *arrayOf(name, databaseId)
)
}
override fun setFolderExtraNumber(name: String, value: Long) {
- database.setLong(
- table = "folder_extra_values",
- column = "value_integer",
- value = value
- )
+ database.execute(false) { db ->
+ val contentValues = ContentValues().apply {
+ put("name", name)
+ put("value_integer", value)
+ put("folder_id", databaseId)
+ }
+ db.insertWithOnConflict("folder_extra_values", null, contentValues, SQLiteDatabase.CONFLICT_REPLACE)
+ }
}
