# Exploring Health Connect Pt. 2 - Reading and Writing Data

DevFeed: [Exploring Health Connect Pt. 2 - Reading and Writing Data](<https://devfeed.tech/articles/exploring-health-connect-pt-2-reading-and-writing-data-38471.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2024-01-19/exploring-health-connect-pt-2-reading-and-writing-data/>)

Author: Eevis Panula

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

Content type: tutorial

Language: en

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

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

Tags: [app](<https://devfeed.tech/tags/app.md>), [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [implementation](<https://devfeed.tech/tags/implementation.md>)

## AI overview

A tutorial on reading and writing menstruation-period data with Health Connect while building a personal period-tracking app. It introduces Health Connect Toolbox for inspecting records and demonstrates a Kotlin function that requests records from the previous 12 months, reads them through the Health Connect client, and stores the results in a view model after checking permissions.

## Source excerpt

I've been building a period tracking app for myself with the help of Health Connect. Last week, I published the first blog post where I explained how to set up Health Connect and asked the user to give permission to use their data. I initially thought I'd write one blog post about building this app - now, it's turning into (at least) three. But I have to say that I've enjoyed this process a lot. This blog post will look into reading and writing data with Health Connect. There will be one more blog post about updating and deleting data before we get to the point where the app looks like in this video: Reading and Writing Data Before going into code, I want to mention one handy app: Health Connect Toolbox. With its help, you can write and read data from Health Connect, which helps debug issues like if the data was saved at all. Trust me, I know. Health Connect Toolbox also helps with the first task we're looking into: Reading records. If you don't have any other app writing that particular type of data to Health Connect, you can use the Health Connect Toolbox to write data and then see that data in your own app. Now, we have the permissions to read and write data from/to Health Connect, so we can add the implementation for those actions. Read Records The first action we're implementing is reading data. Let's start from the closest point to Health Connect: HealthConnectManager, which we defined in the previous blog post. We need a function to read data from Health Connect: // HealthConnectManager.kt suspend fun readMenstruationRecords(): List<MenstruationPeriodRecord> { val request = ReadRecordsRequest( recordType = MenstruationPeriodRecord::class, timeRangeFilter = TimeRangeFilter.after( LocalDateTime.now().minusMonths(12) ), ) val response = healthConnectClient.readRecords(request) return response.records } First, we define the request, which is ReadRecordsRequest. The type is MenstruationPeriodRecord::class, as we want to read menstruation period data from Health Co