properly update the alarm in the database after changing

This commit is contained in:
tibbi
2018-03-05 22:43:55 +01:00
parent 2c0ad467a1
commit 0f8d61c0d0
4 changed files with 13 additions and 1 deletions

View File

@ -60,6 +60,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
db.insert(ALARMS_TABLE_NAME, null, values)
}
fun updateAlarm(alarm: Alarm): Boolean {
val selectionArgs = arrayOf(alarm.id.toString())
val values = fillAlarmContentValues(alarm)
val selection = "$COL_ID = ?"
return mDb.update(ALARMS_TABLE_NAME, values, selection, selectionArgs) == 1
}
private fun fillAlarmContentValues(alarm: Alarm): ContentValues {
return ContentValues().apply {
put(COL_TIME_IN_MINUTES, alarm.timeInMinutes)