Knowledge Base Article

Accessing Samsung Health Data through Health Connect

Health Connect is a platform that enables you to integrate Samsung Health data with your applications, creating new opportunities for health applications that enhance the user's journey towards better health. Using the Health Connect APIs, you can, for example, retrieve a user's Samsung Health data, such as their exercise, sleep, and heart rate information, and send data to the Samsung Health application.

This is the first blog post in a series that introduces you to Health Connect API features and how you can use them in your applications. Let's begin by looking at how Health Connect interacts with Samsung Health data, and the basic workflow. Understanding this is essential for creating applications that use data from Samsung Health and Health Connect.

Samsung Health

Samsung Health is an application that can be installed on Android smartphones and tablets, and on Galaxy Watches. It can use the sensors on the device, including the Galaxy Watch's BioActive sensor, to measure the user's overall health data, including steps, exercises, heart rate, sleep, blood oxygen saturation and body composition.
Let's consider the most common scenario: the Samsung Health application is installed on both the Galaxy Watch and a smartphone. The application synchronizes the measurements between both devices and manages the user's health data securely on them.
For example, if the user measures their blood pressure with the Samsung Health Monitor application on their smartphone, the data can be shared to Samsung Health.

 

Health Connect

Since the Samsung Health application supports various useful health data types and gathers data from all connected devices, developers are very interested in obtaining access to that data. Consequently, Samsung collaborated with Google to build the Health Connect platform, which was released in May 2022. Health Connect enables applications to share health and fitness data across Android devices with the user's consent. For more information about Health Connect, see Health Connect Guide and Health Connect APIs.

Samsung Health has supported synchronizing data with Health Connect since application version 6.22.5, released in October 2022. The Health Connect APIs support devices using Android SDK 28 (Pie) or higher.

Once the user has connected Samsung Health to Health Connect, new or updated data in Samsung Health is shared to Health Connect. This means that your applications can use the Health Connect APIs to access Samsung Health data. Samsung Health synchronizes health data with Health Connect in both directions:

  • When Samsung Health has new or updated data, it writes the data to Health Connect.
  • When Health Connect has updated data, Samsung Health retrieves it.

For example, a blood glucose meter connected to Samsung Health measures the user's blood glucose level. This data is saved in Samsung Health and then sent to Health Connect. Similarly, whenever there is new blood glucose data in Health Connect, Samsung Health retrieves that data and saves it in Samsung Health.

 

To demonstrate how data synchronization works, let's walk through an example of adding nutrition information to Samsung Health.

    1. To start data synchronization between Samsung Health and Health Connect, you must enable it in the Samsung Health application on your Android device. From the Settings menu, select Health Connect. If Health Connect is not installed, you are prompted to install it.

 

 

    1. The first time you access the Health Connect menu item in Samsung Health with the Health Connect application installed, you are asked for permission to share your Samsung Health data with Health Connect. Select the data you consent to sharing, and select Allow.

Samsung Health and Health Connect are now linked and data is shared between them.

    1. To test the data synchronization, in Samsung Health, go to Food tracker and create some nutrition data.

 

 

    1. In Samsung Health, go to Settings > Health Connect, and select Data and access. If Health Connect has received nutrition data from Samsung Health, a Nutrition item appears in the Browse data list.

 

 

    1. To view the synchronized data, select Nutrition.

 



Data synchronization timing

Data synchronization between Samsung Health and Health Connect occurs on the smartphone side. To take advantage of health data collected by a Galaxy Watch, you must understand at which times the Galaxy Watch sends its data to the Samsung Health smartphone application.

 

New or updated health data on each connected device is generally synchronized with Samsung Health in the following situations:

      • The Galaxy Watch reconnects with the smartphone
      • The user opens the Samsung Health application home screen on the smartphone
      • The user pulls down on the Samsung Health application home screen on the smartphone

However, some types of health data are synchronized differently:

      • For battery conservation reasons, continuous heart rate data from the Galaxy Watch is not sent to the Samsung Health application on the smartphone immediately. However, manual heart rate measurements on the watch are synchronized immediately.

Enabling Settings in Samsung Health

To synchronize health data between Samsung Health and Health Connect please consider:

      • Using the latest Samsung Health and Health Connect versions.
        You can check them in Google Play.
        If you're interested in Galaxy Watch's data, check its version too.
      • Allowing data permissions through the following path:
        Samsung Health > Settings > Health Connect > App permissions > Samsung Health
        (Note that you must enter from the Samsung Health settings, not from Health Connect settings.)
      • Synchronizing Samsung Health data in:
        Samsung Health > Settings > Sync with Samsung account > Select the 'Sync now' button in the bottom.

 

Accessing Health Connect APIs

If the user has synchronized their Samsung Health data with Health Connect, you can use the Health Connect APIs to interact with it in various ways. For example:

      • Read and write data: You can retrieve data that has been shared from Samsung Health to Health Connect, and send data to Health Connect to be synchronized to Samsung Health.
      • Delete specific data records: You can remove a specific data point or data of a specific type within a time interval.
      • Aggregate and filter data: You can filter the retrieved data by type or tag and analyze it, such as determining the average, maximum, minimum, or sum of the values.
      • Session data: You can group data into sessions by time interval, such as to generate a sleep or activity session report.

 

Note :

For security reasons, Health Connect data can only be retrieved by applications running in the foreground.

 

The following table lists the various health data that can be synchronized between Samsung Health and Health Connect.

Samsung Health data Corresponding data type of Health Connect
All steps StepsRecord
Blood glucose BloodGlucoseRecord
Blood oxygen saturation OxygenSaturationRecord
Blood pressure BloodPressureRecord
Exercise session ExerciseSessionRecord
TotalCaloriesBurnedRecord
DistanceRecord
Exercise (heart rate) HeartRateRecord
Exercise (power) PowerRecord
Exercise (speed) SpeedRecord
Exercise (VO2max) Vo2MaxRecord
Heart rate HeartRateRecord
Sleep session SleepSessionRecord
Sleep stage SleepStageRecord
Weight /
Body composition
WeightRecord
Body composition BodyFatRecord
Body composition BasalMetabolicRateRecord

 

To get started with implementing Health Connect API functionality in your application:

      1. Add the Health Connect API library dependencies to your application's "build.gradle" file.
      2. Declare the Health Connect application package name in your "AndroidManifest.xml" file.
      3. Check that the user has installed Health Connect, then create the "HealthConnectClient" instance.
      4. Declare the permissions for the health data types you want to use.

Now your application is ready to use the Health Connect APIs.

Other blog posts in this series will explore various Health Connect API use cases in more detail.

Updated 3 years ago
Version 2.0

3 Comments

  • Kh-Larry's avatar
    Kh-Larry
    Community Manager

    Can we get more information on how the sleep tracking works?  Thanks for posting this very helpful article, I love my Galaxy Watch!

  • ashish's avatar
    ashish
    Community Manager

    This is informative. I have been using the Samsung Health application for some time and I am happy with the features it offers.