Filtering and grouping data

Filters

Filters help to limit a query range to get data that are more precise. Samsung Health Data SDK provides time, source, and ID filters. Available filters are different for each data operation.
For instance:

  • IdFilter, ReadSourceFilter, and TimeFilter are available for reading data.
  • AggregateSourceFilter and TimeFilter are available for aggregating data.
  • IdFilter and TimeFilter are available for deleting data.

Time filters

A built request with a start time and end time gives all records that are inside this time range. For that, you can use the following filter types:

  • LocalTimeFilter
  • LocalDateFilter
  • InstantTimeFilter

Source filters

All health data stored in Samsung Heath has the following source information:

  • Source app ID: an app's package name which identifies the app that inserted the data to Samsung Health.
  • Source device ID: representing a device which measures or creates the data.

ReadSourceFilter supports the following functions:

  • fromApplicationId: an app's package name
  • fromDeviceType: a device type such as MOBILE or WATCH
  • fromLocalDevice: a device with Samsung Health installed
  • fromPlatform: measured or inserted by Samsung Health

AggregateSourceFilter supports the fromPlatform function.

ID filter

This filter is for setting Data UIDs or Client Data IDs. Client Data ID is a unique identifier that you may have set while inserting data.

Grouping retrieved data

Retrieved health data can be grouped into time segments with:

  • InstantTimeGroup: MINUTELY, HOURLY, and DAILY
  • LocalDateGroup: DAILY, WEEKLY, MONTHLY, and YEARLY
  • LocalTimeGroup: MINUTELY, HOURLY, and DAILY