Health Data Store
The SDK provides the health data store to access the health data with a user’s consent. The data in the health data store can be shared with other partner apps also.
Preparing Data Access
An application needs to connect the health data store, and acquire data permission to access the data in the health data store. The following figure shows a basic flow for working with Samsung Health.
In case of connection failure, 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 data with APIs of the following figure.
All queries except inserting data can be requested through a filter to set the target range for a query. A data query is sent asynchronously or synchronously.
Asynchronous query is used usually and you can select one of the methods for your need. See the following examples for more information.
The query result is retrieved as the following table.
See data query snippets in API Reference.
HealthDataResolver.Filter is very useful to clear the data range for reading, updating, and aggregating health data. Multiple filters can be combined with:
See more descriptions in API Reference.
The health data is stored based on the normalized unit as defined in International System of Unit (SI) in the following table.
Data normalization enables your application to read health data without the specific unit. It means that you should be careful to unify the data units when inserting health data to the health data store.
HealthDataUnit helps to convert data value between different units.