read

suspend fun <T : DataPoint, S : ReadDataRequest.Builder<T>> HealthDataStore.read(type: DataType.Readable<T, S>, builder: suspend S.() -> S? = null): DataResponse<T>

Reads a set of data in the Samsung Health app with simplified code. It enables you to read health data with a specific data type and building a ReadDataRequest for that data type easily. To read data asynchronously, use HealthDataStore.readDataAsync.

The below sample code shows how to read health data.

val healthDataStore = HealthDataService.getStore(context) // get the store instance from the SDK
val startOfDay = LocalDate.now().atStartOfDay()
val now = LocalDateTime.now()
val localTimeFilter = LocalDateFilter.of(startOfDay, now)

val result = healthDataStore.read(DataTypes.Nutrition){
    setLocalTimeFilter(localTimeFilter)
}

Return

The DataResponse instance that includes a DataPoint list.

Since

1.0.0

Parameters

type

A Readable data type to read.

builder

A lambda function to build the ReadDataRequest according to the data type.

Preferences Submitted

You have successfully updated your cookie preferences.