Health Connect stores and structures health and fitness data. It also accounts for how different data types are measured. These data types include heart rate measurements taken immediately, step count taken over time, and sleep data taken in sessions.
It's important to understand first what data types and permissions Health Connect offers so that you can plan your app's requirements. With that, you need to review your data types before you can finalize your requirements.
Data type categories
Health Connect supports data types that are used across most health and fitness apps to provide as much variety as possible. Health Connect aims to offer a comprehensive view and storage of health and fitness data. These data types fall into the following categories:
- Activity: This captures any activity that a user does. It can include health and fitness activities like running and swimming.
- Body Measurement: This captures common data related to the body, such as a user's weight and their basal metabolic rate.
- Cycle Tracking: This captures menstrual cycles and related data points, such as the binary result of an ovulation test.
- Nutrition: This captures hydration and nutrition data types. The former represents how much water a user consume in a single drink. The latter includes optional fields such as calories, sugar, and magnesium.
- Sleep: This captures interval data related to a user's length and type of sleep.
- Vitals: This captures essential information about the user's general health. It includes data such as body temperature, blood glucose, blood pressure, and blood oxygen saturation.
Data type format
Data types in Health Connect are stored in objects that are subclasses of
Record
.
For each data type, there are associated fields that are either generic such as
time
and zoneOffset
, or specific such as title
, count
, and percentage
.
Some fields use simple types—such as long, double, or string—while others use
complex types like enumerations and classes like Instant
and
ZoneOffset
. The attributes of these fields can be required or
optional. Some attributes are read-only, and some attributes are clamped to a
specific range of values.
For the full list of available data types and their fields, refer to the classes in Jetpack.
Additional data attributes
Data in the Health Connect API also includes metadata attributes described in the following list:
- Health Connect ID: Each point of data is assigned with a unique identifier (UID) upon creation. This is useful for standard read and write operations. See Health Connect ID for more details.
- Last modified time: This marks the timestamp the last instance a record has an update. It's automatically generated on the first creation of the record or on every update.
- Data origin: Health Connect stores information about the app where the data came from. It contains the package name of that origin, which is automatically added upon creation.
- Device: Health Connect stores information about the device where the data came from. It contains the manufacturer and model of that device, which you manually supply the value.
- Client ID: Health Connect provides Client IDs so that client apps can refer to data using their own IDs, which helps with conflict resolution and makes syncing easier. This is supplied to the record manually.
- Client record version: Along with the Client ID, Health Connect provides versioning to help tracking changes during data syncing. This is supplied to the record manually.
- Recording method: Health Connect lets you understand how data is recorded. These methods include apps recording data passively (automatically), and users recording data actively or manually.
Health Connect ID
Health Connect assigns unique identifiers (UIDs) to newly inserted data objects, which identify data objects and distinguish them from others. Health Connect IDs are useful in read or write requests. Health Connect IDs aren't identical to Client IDs. A client app assigns Client IDs, while Health Connect exclusively assigns Health Connect IDs.
Keep in mind of the following notes when working with Health Connect IDs:
- Sessions have a single Health Connect ID, but data within sessions have their own Health Connect IDs.
- Health Connect IDs aren't tied or related to timestamps.
- Some use cases might require storing a specific Health Connect ID during a workflow. For example, a specific ID is required to retrieve and show to a user the data entry that they just logged.
Time in Health Connect
All data written to Health Connect must specify the zone offset information. Specifying the zone offset enables apps to read the data to represent it in civil time. Civil time is the time that is local and relevant to the user, but not necessarily in Coordinated Universal Time (UTC).
In rare circumstances, the zone offset might not be available. When this occurs in Android 14 (API Level 34), Health Connect sets the zone offset based on the system default time zone of the device. In Android 13 and lower versions (API Level 33 and lower), it's possible to write to Health Connect without specifying any zone offset information, which must be avoided whenever possible.
Time and zone setting
Specifying zone offset information while writing data provides time zone information when reading data in Health Connect. However, it may fail to do so in certain situations, such as when the zone offset isn't provided. Your app needs to be prepared to deal with both kinds of data, in a way that makes sense for your specific circumstances.
Permissions
Before requesting any permissions, your app must declare them in the manifest first. See the following tables for the full mapping of data types and their permissions.
For 1.0.0-alpha10 and higher
Record class type | Read and write permission declaration |
---|---|
ActiveCaloriesBurned |
android.permission.health.READ_ACTIVE_CALORIES_BURNED
android.permission.health.WRITE_ACTIVE_CALORIES_BURNED |
BasalBodyTemperature |
android.permission.health.READ_BASAL_BODY_TEMPERATURE
android.permission.health.WRITE_BASAL_BODY_TEMPERATURE |
BasalMetabolicRate |
android.permission.health.READ_BASAL_METABOLIC_RATE
android.permission.health.WRITE_BASAL_METABOLIC_RATE |
BloodGlucose |
android.permission.health.READ_BLOOD_GLUCOSE
android.permission.health.WRITE_BLOOD_GLUCOSE |
BloodPressure |
android.permission.health.READ_BLOOD_PRESSURE
android.permission.health.WRITE_BLOOD_PRESSURE |
BodyFat |
android.permission.health.READ_BODY_FAT
android.permission.health.WRITE_BODY_FAT |
BodyTemperature |
android.permission.health.READ_BODY_TEMPERATURE
android.permission.health.WRITE_BODY_TEMPERATURE |
BodyWaterMass |
android.permission.health.READ_BODY_WATER_MASS
android.permission.health.WRITE_BODY_WATER_MASS |
BoneMass |
android.permission.health.READ_BONE_MASS
android.permission.health.WRITE_BONE_MASS |
CervicalMucus |
android.permission.health.READ_CERVICAL_MUCUS
android.permission.health.WRITE_CERVICAL_MUCUS |
CyclingPedalingCadence |
android.permission.health.READ_EXERCISE
android.permission.health.WRITE_EXERCISE |
Distance |
android.permission.health.READ_DISTANCE
android.permission.health.WRITE_DISTANCE |
ElevationGained |
android.permission.health.READ_ELEVATION_GAINED
android.permission.health.WRITE_ELEVATION_GAINED |
ExerciseSession |
android.permission.health.READ_EXERCISE
android.permission.health.WRITE_EXERCISE |
FloorsClimbed |
android.permission.health.READ_FLOORS_CLIMBED
android.permission.health.WRITE_FLOORS_CLIMBED |
HeartRate |
android.permission.health.READ_HEART_RATE
android.permission.health.WRITE_HEART_RATE |
HeartRateVariabilityRmssd |
android.permission.health.READ_HEART_RATE_VARIABILITY
android.permission.health.WRITE_HEART_RATE_VARIABILITY |
Height |
android.permission.health.READ_HEIGHT
android.permission.health.WRITE_HEIGHT |
Hydration |
android.permission.health.READ_HYDRATION
android.permission.health.WRITE_HYDRATION |
IntermenstrualBleeding |
android.permission.health.READ_INTERMENSTRUAL_BLEEDING
android.permission.health.WRITE_INTERMENSTRUAL_BLEEDING |
LeanBodyMass |
android.permission.health.READ_LEAN_BODY_MASS
android.permission.health.WRITE_LEAN_BODY_MASS |
MenstruationFlow |
android.permission.health.READ_MENSTRUATION
android.permission.health.WRITE_MENSTRUATION |
MenstruationPeriod |
android.permission.health.READ_MENSTRUATION
android.permission.health.WRITE_MENSTRUATION |
Nutrition |
android.permission.health.READ_NUTRITION
android.permission.health.WRITE_NUTRITION |
OvulationTest |
android.permission.health.READ_OVULATION_TEST
android.permission.health.WRITE_OVULATION_TEST |
OxygenSaturation |
android.permission.health.READ_OXYGEN_SATURATION
android.permission.health.WRITE_OXYGEN_SATURATION |
PlannedExercise |
android.permission.health.READ_PLANNED_EXERCISE
android.permission.health.WRITE_PLANNED_EXERCISE |
Power |
android.permission.health.READ_POWER
android.permission.health.WRITE_POWER |
RespiratoryRate |
android.permission.health.READ_RESPIRATORY_RATE
android.permission.health.WRITE_RESPIRATORY_RATE |
RestingHeartRate |
android.permission.health.READ_RESTING_HEART_RATE
android.permission.health.WRITE_RESTING_HEART_RATE |
SexualActivity |
android.permission.health.READ_SEXUAL_ACTIVITY
android.permission.health.WRITE_SEXUAL_ACTIVITY |
SkinTemperature |
androidx.health.permission.SkinTemperature.READ
androidx.health.permission.SkinTemperature.WRITE |
SleepSession |
android.permission.health.READ_SLEEP
android.permission.health.WRITE_SLEEP |
Speed |
android.permission.health.READ_SPEED
android.permission.health.WRITE_SPEED |
StepsCadence |
android.permission.health.READ_STEPS
android.permission.health.WRITE_STEPS |
Steps |
android.permission.health.READ_STEPS
android.permission.health.WRITE_STEPS |
TotalCaloriesBurned |
android.permission.health.READ_TOTAL_CALORIES_BURNED
android.permission.health.WRITE_TOTAL_CALORIES_BURNED |
Vo2Max |
android.permission.health.READ_VO2_MAX
android.permission.health.WRITE_VO2_MAX |
Weight |
android.permission.health.READ_WEIGHT
android.permission.health.WRITE_WEIGHT |
WheelchairPushes |
android.permission.health.READ_WHEELCHAIR_PUSHES
android.permission.health.WRITE_WHEELCHAIR_PUSHES |
For 1.0.0-alpha09 and lower
Record class type | Read and write permission declaration |
---|---|
ActiveCaloriesBurned |
androidx.health.permission.ActiveCaloriesBurned.READ
androidx.health.permission.ActiveCaloriesBurned.WRITE |
BasalBodyTemperature |
androidx.health.permission.BasalBodyTemperature.READ
androidx.health.permission.BasalBodyTemperature.WRITE |
BasalMetabolicRate |
androidx.health.permission.BasalMetabolicRate.READ
androidx.health.permission.BasalMetabolicRate.WRITE |
BloodGlucose |
androidx.health.permission.BloodGlucose.READ
androidx.health.permission.BloodGlucose.WRITE |
BloodPressure |
androidx.health.permission.BloodPressure.READ
androidx.health.permission.BloodPressure.WRITE |
BodyFat |
androidx.health.permission.BodyFat.READ
androidx.health.permission.BodyFat.WRITE |
BodyTemperature |
androidx.health.permission.BodyTemperature.READ
androidx.health.permission.BodyTemperature.WRITE |
BodyWaterMass |
androidx.health.permission.BodyWaterMass.READ
androidx.health.permission.BodyWaterMass.WRITE |
BoneMass |
androidx.health.permission.BoneMass.READ
androidx.health.permission.BoneMass.WRITE |
CervicalMucus |
androidx.health.permission.CervicalMucus.READ
androidx.health.permission.CervicalMucus.WRITE |
CyclingPedalingCadence |
androidx.health.permission.CyclingPedalingCadence.READ
androidx.health.permission.CyclingPedalingCadence.WRITE |
Distance |
androidx.health.permission.Distance.READ
androidx.health.permission.Distance.WRITE |
ElevationGained |
androidx.health.permission.ElevationGained.READ
androidx.health.permission.ElevationGained.WRITE |
ExerciseSession |
androidx.health.permission.ExerciseSession.READ
androidx.health.permission.ExerciseSession.WRITE |
FloorsClimbed |
androidx.health.permission.FloorsClimbed.READ
androidx.health.permission.FloorsClimbed.WRITE |
HeartRate |
androidx.health.permission.HeartRate.READ
androidx.health.permission.HeartRate.WRITE |
HeartRateVariabilityRmssd |
androidx.health.permission.HeartRateVariabilityRmssd.READ
androidx.health.permission.HeartRateVariabilityRmssd.WRITE |
Height |
androidx.health.permission.Height.READ
androidx.health.permission.Height.WRITE |
Hydration |
androidx.health.permission.Hydration.READ
androidx.health.permission.Hydration.WRITE |
IntermenstrualBleeding |
androidx.health.permission.IntermenstrualBleeding.READ
androidx.health.permission.IntermenstrualBleeding.WRITE |
LeanBodyMass |
androidx.health.permission.LeanBodyMass.READ
androidx.health.permission.LeanBodyMass.WRITE |
MenstruationFlow |
androidx.health.permission.MenstruationFlow.READ
androidx.health.permission.MenstruationFlow.WRITE |
Nutrition |
androidx.health.permission.Nutrition.READ
androidx.health.permission.Nutrition.WRITE |
OvulationTest |
androidx.health.permission.OvulationTest.READ
androidx.health.permission.OvulationTest.WRITE |
OxygenSaturation |
androidx.health.permission.OxygenSaturation.READ
androidx.health.permission.OxygenSaturation.WRITE |
Power |
androidx.health.permission.Power.READ
androidx.health.permission.Power.WRITE |
RespiratoryRate |
androidx.health.permission.RespiratoryRate.READ
androidx.health.permission.RespiratoryRate.WRITE |
RestingHeartRate |
androidx.health.permission.RestingHeartRate.READ
androidx.health.permission.RestingHeartRate.WRITE |
SexualActivity |
androidx.health.permission.SexualActivity.READ
androidx.health.permission.SexualActivity.WRITE |
SleepSession |
androidx.health.permission.SleepSession.READ
androidx.health.permission.SleepSession.WRITE |
Speed |
androidx.health.permission.Speed.READ
androidx.health.permission.Speed.WRITE |
StepsCadence |
androidx.health.permission.StepsCadence.READ
androidx.health.permission.StepsCadence.WRITE |
Steps |
androidx.health.permission.Steps.READ
androidx.health.permission.Steps.WRITE |
TotalCaloriesBurned |
androidx.health.permission.TotalCaloriesBurned.READ
androidx.health.permission.TotalCaloriesBurned.WRITE |
Vo2Max |
androidx.health.permission.Vo2Max.READ
androidx.health.permission.Vo2Max.WRITE |
Weight |
androidx.health.permission.Weight.READ
androidx.health.permission.Weight.WRITE |
WheelchairPushes |
androidx.health.permission.WheelchairPushes.READ
androidx.health.permission.WheelchairPushes.WRITE |
Review your data types and permissions
Now that you have your data types and permissions planned out, you can implement them during development.
When reviewing your app prior to uploading it to the Play Store, double-check the list of data types and permissions that your app requires. This lets you accurately declare your app's data use.
When you prepare to publish your app to the Play Store, declare access to the Health Connect data types that your app uses. Otherwise, users might be prompted with an error message where your app can't access the Health Connect data types because they require special approval.