Health Data Store

Samsung Health SDK provides the health data store to access health data with the user’s consent. Data in the Samsung Health’s health data store can be shared with other partner apps also.

Figure 12: Samsung Health data store

Preparing Data Access

An application needs to initialize the health data service, connect to the health data store, and acquire data permission to access the health data store’s data. Figure 13 shows a basic flow and main APIs for working with Samsung Health.

Figure 13: Flow for data access

In the connection failure case, all exceptions should be handled clearly with a proper message to the user. It helps to prevent unexpected operations on your application. For detailed code, see:

Health Data Query

HealthDataResolver helps to access the health data store’s data with APIs of Figure 14.

Figure 14: Health data query

All queries except inserting data can be requested with the filter to set the target range for a query. And a data query is sent asynchronously or synchronously.

Asynchronous query is used usually and you can select one of methods for your need. See the following examples for more information.

The query result is retrieved as Table 4.

Request Result
insert()
update()
delete()
BaseResult
read() ReadResult
aggregate() AggregateResult
Table 4: Data request and its result

See data query snippets in API Reference.

Filter

HealthDataResolver.Filter is very useful to clear the data range for reading, updating, and aggregating health data. Multiple filters can be combined with:

  • and()

  • or()

See more descriptions in API Reference.

Data Normalization

The health data is stored based on the normalized unit as defined in International System of Unit (SI) in Table 5.

  • Item Unit
    Height cm
    Weight kg
    Temperature Celsius
    Blood glucose mmol/L
    Blood pressure mmHg
    HbA1c %
    SpO2 %
  • Item Unit
    Calorie kcal
    Speed m/s
    Distance meter
    Time millisecond
    Water intake ml
    Caffeine intake mg
Table 5: International System of Unit

It enables your application to read health data without the specific unit. It means that you need to be careful to unify the data units when you insert health data to the health data store. HealthDataUnit helps to convert data value between different units.