com.samsung.android.sdk.healthdata

Class HealthDataResolver.UpdateRequest.Builder

  • java.lang.Object
    • com.samsung.android.sdk.healthdata.HealthDataResolver.UpdateRequest.Builder
  • Enclosing interface:
    HealthDataResolver.UpdateRequest


    public static class HealthDataResolver.UpdateRequest.Builder
    extends Object
    This class is a builder to configure HealthDataResolver.UpdateRequest. Only inserted health data by your application can be updated. The following example shows how to update calrories of existing health data.

       public class HealthDataResolverExample {
      
           private HealthDataResolver.UpdateRequest buildUpdateRequest() {
               HealthDevice myDevice = new HealthDeviceManager(mStore).getLocalDevice();
      
               HealthData data = new HealthData();
               data.setSourceDevice(myDevice.getUuid());
               data.putFloat(HealthConstants.Nutrition.CALORIE, 100);
      
               HealthDataResolver.Filter filter = HealthDataResolver.Filter.eq(HealthConstants.Nutrition.CALORIE, 10000);
      
               // Build a request to update nutrition data which its calories is 10000 to 100
               HealthDataResolver.UpdateRequest request = new HealthDataResolver.UpdateRequest.Builder()
                   .setDataType(HealthConstants.Nutrition.HEALTH_DATA_TYPE)
                   .setFilter(filter)
                   .setHealthData(data)
                   .build();
      
               return request;
           }
       }

    Since:
    1.0.0
    • Method Detail

      • setHealthData

        public HealthDataResolver.UpdateRequest.Builder setHealthData(HealthData object)
        Sets a health data object to update. It has to be specified before calling build().
        Parameters:
        object - The health data object to update. The source device of object should be valid.
        Returns:
        The object that applies health data to update
        Since:
        1.0.0
      • setSourceDevices

        public HealthDataResolver.UpdateRequest.Builder setSourceDevices(List<String> uuidList)
        Sets a UUID list of source devices for health data to be updated.
        Parameters:
        uuidList - The UUID list for source devices
        Returns:
        The object that applies source devices
        Since:
        1.0.0
      • setLocalTimeRange

        public HealthDataResolver.UpdateRequest.Builder setLocalTimeRange(String timeProperty,
                                                                          String offsetProperty,
                                                                          long begin,
                                                                          long end)
        Sets the local time range not to miss data from the query's result when there exist data with a different TIME_OFFSET in the saved health data.

        The data that has a different TIME_OFFSET with other data's TIME_OFFSET can be saved when the daylight time is applied or the user moves to another region by like a travel. Building a complete query to aggregate all data including the different TIME_OFFSET is not easy.
        Use this API to build an aggregate request as possible.

        Parameters:
        timeProperty - The time property name that needs to add a filter
        offsetProperty - The time offset property
        begin - The beginning time with GMT+0 milliseconds.
        E.g. If you would like to update data from 00:00:00 on October 26th, 2021 in your region, set the value with 1635206400000.
        See sample codes.
        Its minimum value is Long.MIN_VALUE.
        end - The end time with GMT+0 milliseconds.
        E.g. If you would like to update data until 00:00:00 on October 26th, 2021 in your region, set the value with 1635206400000.
        See sample codes.
        Its maximum value is Long.MAX_VALUE.
        Returns:
        The object that applies the local time range
        Since:
        1.5.0