Review Health Connect functionality
Stay organized with collections
Save and categorize content based on your preferences.
This page describes the main functions of the Health Connect API.
CRUD operations on record and data synchronization
The platform provides standard insert, update, and delete functions for recorded
data. Health Connect also includes functionality that allows client apps to
synchronize data out of Health Connect. This produces a log of data changes
that shows the developer and user whether certain data types have been
inserted or deleted by other apps.
Basic aggregation functions
Clients can apply an aggregation function over underlying data, providing the
following:
- The average, minimum or maximum values (for example, the minimum and
maximum heart rate during an activity session).
- The sum total (for example, the total step count in a daily interval).
- A simple count of the number of underlying measurements (for
example, the number of activity sessions in a given week).
- The total duration on supported data types (for example, time spent in
deep sleep this week, or total duration of activity sessions today).
Availability checks
Health Connect is compatible with Android SDK version 28 (Pie) and higher.
The SDK allows client apps to determine whether the Health Connect API is on
the user's Android-powered device. If it isn't, Health Connect triggers an
availability check to determine whether the user's device is compatible.
Permission checks
Health Connect requires you to request the user's permission to read and
write their health and fitness data on a per-app basis. It also lets you
see what permissions have already been granted or denied by the user.
Reading with Health Connect
Foreground reading
You can normally read data from Health Connect when your app is
in the foreground. In these cases, you may consider using a foreground service
to run this operation in case the user or system places your app
in the background during a read operation.
For situations in which your app may expect an interruption, such as displaying
a reading in your application, read directly from Health Connect to your client
application.
For situations in which you prefer your app to run without
interruptions, use a
foreground service:
FOREGROUND_SERVICE_TYPE_HEALTH
: Allows app to remain in
the foreground to collect sensor data, such as a workout app that continues
to collect data even when the user puts the app in the background.
FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
: A generic-type
service that allows an app to continue to collect critical data for
tasks that take less than three minutes,
even if the user places the app in the background before it completes.
Background reading
You can request that your application run in the background and read data from
Health Connect. If you request the
Background Read
permission, your user can grant your app access to read data in the background.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-17 UTC."],[],[],null,["# Review Health Connect functionality\n\nThis page describes the main functions of the Health Connect API.\n\nCRUD operations on record and data synchronization\n--------------------------------------------------\n\nThe platform provides standard insert, update, and delete functions for recorded\ndata. Health Connect also includes functionality that allows client apps to\nsynchronize data out of Health Connect. This produces a log of data changes\nthat shows the developer and user whether certain data types have been\ninserted or deleted by other apps.\n\nBasic aggregation functions\n---------------------------\n\nClients can apply an aggregation function over underlying data, providing the\nfollowing:\n\n- The **average, minimum or maximum** values (for example, the minimum and maximum heart rate during an activity session).\n- The **sum total** (for example, the total step count in a daily interval).\n- A **simple count** of the number of underlying measurements (for example, the number of activity sessions in a given week).\n- The **total duration** on supported data types (for example, time spent in deep sleep this week, or total duration of activity sessions today).\n\nAvailability checks\n-------------------\n\nHealth Connect is compatible with Android SDK version 28 (Pie) and higher.\nThe SDK allows client apps to determine whether the Health Connect API is on\nthe user's Android-powered device. If it isn't, Health Connect triggers an\navailability check to determine whether the user's device is compatible.\n\nPermission checks\n-----------------\n\nHealth Connect requires you to request the user's permission to read and\nwrite their health and fitness data on a per-app basis. It also lets you\nsee what permissions have already been granted or denied by the user.\n\nReading with Health Connect\n---------------------------\n\n### Foreground reading\n\nYou can normally read data from Health Connect when your app is\nin the foreground. In these cases, you may consider using a foreground service\nto run this operation in case the user or system places your app\nin the background during a read operation.\n\nFor situations in which your app may expect an interruption, such as displaying\na reading in your application, read directly from Health Connect to your client\napplication.\n\nFor situations in which you prefer your app to run without\ninterruptions, use a\n[foreground service](/develop/background-work/services/fgs):\n\n- [`FOREGROUND_SERVICE_TYPE_HEALTH`](/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_HEALTH): Allows app to remain in\n the foreground to collect sensor data, such as a workout app that continues\n to collect data even when the user puts the app in the background.\n\n- [`FOREGROUND_SERVICE_TYPE_SHORT_SERVICE`](/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE): A generic-type\n service that allows an app to continue to collect critical data for\n tasks that take less than three minutes,\n even if the user places the app in the background before it completes.\n\n### Background reading\n\nYou can request that your application run in the background and read data from\nHealth Connect. If you request the\n[Background Read](/health-and-fitness/guides/health-connect/develop/read-data#background-read-example)\npermission, your user can grant your app access to read data in the background."]]