diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index e64d3a194e..c05d04f0db 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -150,8 +150,10 @@ class AutomationPlugin @Inject constructor( private fun storeToSP() { val array = JSONArray() + val iterator = automationEvents.iterator() try { - for (event in automationEvents) { + while (iterator.hasNext()) { + val event = iterator.next() array.put(JSONObject(event.toJSON())) } } catch (e: JSONException) {