delete children events at deleting the parent

This commit is contained in:
tibbi 2017-06-13 23:56:25 +02:00
parent 4b2ebcafd3
commit b4e935722c
1 changed files with 23 additions and 0 deletions

View File

@ -326,6 +326,29 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
ids.forEach { ids.forEach {
context.cancelNotification(it.toInt()) context.cancelNotification(it.toInt())
} }
deleteChildEvents(args)
}
private fun deleteChildEvents(ids: String) {
val projection = arrayOf(COL_ID)
val selection = "$COL_PARENT_EVENT_ID IN ($ids)"
val childIds = ArrayList<String>()
var cursor: Cursor? = null
try {
cursor = mDb.query(MAIN_TABLE_NAME, projection, selection, null, null, null, null)
if (cursor?.moveToFirst() == true) {
do {
childIds.add(cursor.getStringValue(COL_ID))
} while (cursor.moveToNext())
}
} finally {
cursor?.close()
}
if (childIds.isNotEmpty())
deleteEvents(childIds.toTypedArray())
} }
fun addEventRepeatException(parentEventId: Int, occurrenceTS: Int) { fun addEventRepeatException(parentEventId: Int, occurrenceTS: Int) {