# Exploring Health Connect pt. 3 - Updating and Deleting Data

DevFeed: [Exploring Health Connect pt. 3 - Updating and Deleting Data](<https://devfeed.tech/articles/exploring-health-connect-pt-3-updating-and-deleting-data-38472.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2024-01-28/exploring-health-connect-pt-3-updating-and-deleting-data/>)

Author: Eevis Panula

Published: 2025-06-11T04:24:54.677000Z

Content type: tutorial

Language: en

Sources: [Eevis Blog](<https://devfeed.tech/sources/eevis-blog.md>)

Topics: [data](<https://devfeed.tech/topics/data.md>), [App](<https://devfeed.tech/topics/app.md>), [function](<https://devfeed.tech/topics/function.md>), [ui](<https://devfeed.tech/topics/ui.md>), [enum](<https://devfeed.tech/topics/enum.md>)

Tags: [app](<https://devfeed.tech/tags/app.md>), [data](<https://devfeed.tech/tags/data.md>), [function](<https://devfeed.tech/tags/function.md>), [ui](<https://devfeed.tech/tags/ui.md>), [version](<https://devfeed.tech/tags/version.md>)

## AI overview

This tutorial, the third and final post in a series, explains how to update and delete menstruation-period records in Health Connect. It shows the supporting changes in the Health Connect manager, view model, and UI, including refreshing records after updates and obtaining record identifiers for deletion.

## Source excerpt

I've been building a period tracking app for myself, and my other goal has been to explore Health Connect. There are already two blog posts in this series: Exploring Health Connect Pt. 1 - Setting Up Permissions Exploring Health Connect Pt. 2 - Reading and Writing Data This is the third (and last) blog post of the MVP version of this period tracker. We'll look into updating and deleting Health Connect data. After changes in this blog post, the app will look like this: So, let's start with allowing the user to update data. Update Records Updating records is pretty straightforward after the changes we made in the context of the last blog post. First, in Health Connect Manager, we add updateMenstruationRecords-function: // HealthConnectManager.kt suspend fun updateMenstruationRecords( menstruationPeriodRecord: MenstruationPeriodRecord ) { try { healthConnectClient.updateRecords( listOf(menstruationPeriodRecord), ) Toast.makeText(context, "Successfully updated records", Toast.LENGTH_SHORT).show() } catch (e: Exception) { Toast.makeText(context, e.message.toString(), Toast.LENGTH_SHORT).show() Log.e("Error", "Message: ${e.message}") } } It works the same way as writing - takes in a record, calls Health Connect Client's function updateRecords with a list of records, and then shows a toast message if an update is successful. Then, in the view model, we add a function to call updateMenstruationRecords in Health Connect Manager: // PeriodViewModel.kt fun updateMenstruationRecord( menstruationPeriodRecord: MenstruationPeriodRecord ) { viewModelScope.launch { tryWithPermissionsCheck { healthConnectManager .updateMenstruationRecords( menstruationPeriodRecord ) getPeriodRecords() } } } After a successful update, we re-read the records from Health Connect to update our UI as we did with the write-action. Then, in the UI layer, we don't need to modify the DateRangePickerDialog, as the functionality already returns an updated record when the user presses the "Save"-button. However,