readChanges

abstract suspend fun <T : DataPoint> readChanges(request: ChangedDataRequest<T>): DataResponse<Change<T>>

Reads a set of changes made in the Samsung Health app's data according to the specified request.

This method returns the changes made to a data point, consisting of the type of change, the time change was made, and the updated data point or the deleted data uid. If there are multiple changes in a data point, only the status of the last change is returned. For example, if data is first inserted and then deleted, the method only returns the DELETE change. The example code for retrieving the changes since a specific time is as follows:

val changeRequest = DataTypes.HEART_RATE.changedDataRequestBuilder
    .setChangeTimeFilter(localTimeFilter.of(lastSyncTime, now)
    .build()

val results = healthDataStore.readChanges(changeRequest).dataList

results.forEach { change ->
    if(change.changeType == ChangeType.UPSERT) {
        val upsertDataPoint = change.upsertDataPoint
        // Handle the inserted or updated DataPoint.
    } else if(change.changeType == ChangeType.DELETE) {
        val deletedDataUid = change.deleteDataUid
        // Handle the deleted data uid.
    }
}

Return

The DataResponse instance that returns a set of Changes.

Since

1.0.0

Parameters

request

A ChangedDataRequest instance to specify the conditions for reading the changes.

Preferences Submitted

You have successfully updated your cookie preferences.