com.samsung.android.sdk.healthdata
Class HealthData
- java.lang.Object
-
- com.samsung.android.sdk.healthdata.HealthData
-
- All Implemented Interfaces:
- Parcelable
public final class HealthData extends Object implements Parcelable
This class presents a health data object for a specified health data type, e.g. the blood pressure or weight.Handling Health Data
Quantitative and qualitative values of health data can be specified through this class. Set each property value of health data based on its data type definition and manage it with
HealthDataResolver
.The data type definitions are described in Samsung Health's data types.
Example
See inserting health data.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor and Description HealthData()
Creates a health data instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
clear()
Clears values of all properties in the health data object.byte[]
getBlob(String key)
Gets a BLOB value associated with a given property.double
getDouble(String key)
Gets a double value associated with a given property.float
getFloat(String key)
Gets a float value associated with a given property.InputStream
getInputStream(String key)
Gets an InputStream associated with a given property.int
getInt(String key)
Gets an integer value associated with a given property.long
getLong(String key)
Gets a long value associated with a given property.String
getSourceDevice()
Gets the source device which provides health data.String
getString(String key)
Gets a text value associated with a given property.String
getUuid()
Gets the unique ID of the object.void
putBlob(String key, byte[] value)
Inserts a BLOB value into a given property of the health data object.void
putDouble(String key, double value)
Puts a double value into the given property of the health data object.void
putFloat(String key, float value)
Puts a float value into a given property of the health data object.void
putInputStream(String key, InputStream value)
Inserts anInputStream
into a given property of the health data object.void
putInt(String key, int value)
Puts an integer value into a given property of the health data object.void
putLong(String key, long value)
Puts a long value into a given property of the health data object.void
putNull(String key)
Inserts anull
value into a given property of the health data object.void
putString(String key, String value)
Puts a text value into a given property of the health data object.void
setSourceDevice(String deviceUuid)
Sets the source device which provides health data.
-
-
-
Method Detail
-
getUuid
public String getUuid()
Gets the unique ID of the object.
UsegetString()
to get the data's UUID from a result in:- Returns:
- The unique ID contained in the object
- Throws:
UnsupportedOperationException
- If the health data is inHealthDataResolver.AggregateResult
orHealthDataResolver.ReadResult
- Since:
- 1.0.0
-
getSourceDevice
public String getSourceDevice()
Gets the source device which provides health data.- Returns:
- The ID of the source device which provides health data
- Since:
- 1.0.0
-
setSourceDevice
public void setSourceDevice(String deviceUuid)
Sets the source device which provides health data. It's mandatory to set the source device for created health data.- Parameters:
deviceUuid
- The source device ID which provides health data- Since:
- 1.0.0
-
getString
public String getString(String key)
Gets a text value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is text.
- Returns:
- The text value, or
null
if the health data object does not have the given property - Since:
- 1.0.0
-
getFloat
public float getFloat(String key)
Gets a float value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is float.
- Returns:
- The float value, or
0.0f
if the health data object does not have the given property - Since:
- 1.0.0
-
getDouble
public double getDouble(String key)
Gets a double value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is double- Returns:
- The double value, or
0.0d
if the desired type does not exist for the given property - Since:
- 1.0.0
-
getLong
public long getLong(String key)
Gets a long value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is long.
- Returns:
- The long value, or
0L
if the desired type does not exist for the given property - Since:
- 1.0.0
-
getInt
public int getInt(String key)
Gets an integer value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is integer.
- Returns:
- The integer value, or
0
if the desired type does not exist for the given property - Since:
- 1.0.0
-
getBlob
public byte[] getBlob(String key)
Gets a BLOB value associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is BLOB.
- Returns:
- The BLOB value, or
null
if the desired type does not exist for the given property - Since:
- 1.0.0
-
getInputStream
public InputStream getInputStream(String key)
Gets an InputStream associated with a given property.- Parameters:
key
- The specific property name of health data that its value type is FILE.
- Returns:
- The
InputStream
object, or
null
if the desired type does not exist for the given property - Since:
- 1.3.0
-
putInt
public void putInt(String key, int value)
Puts an integer value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is integer.
value
- The integer value for the given property- Since:
- 1.0.0
-
putLong
public void putLong(String key, long value)
Puts a long value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is long.
value
- The long value for the given property- Since:
- 1.0.0
-
putFloat
public void putFloat(String key, float value)
Puts a float value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is float.
value
- The float value for the given property- Since:
- 1.0.0
-
putDouble
public void putDouble(String key, double value)
Puts a double value into the given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is doublevalue
- The double value for the given property- Since:
- 1.0.0
-
putString
public void putString(String key, String value)
Puts a text value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is text.
value
- The text value for the given property- Since:
- 1.0.0
-
putBlob
public void putBlob(String key, byte[] value)
Inserts a BLOB value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type is BLOB
value
- The BLOB value for the given property- Since:
- 1.0.0
-
putInputStream
public void putInputStream(String key, InputStream value)
Inserts anInputStream
into a given property of the health data object.
The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name that its value type isFile
value
- TheInputStream
object for the given property- Since:
- 1.3.0
-
putNull
public void putNull(String key)
Inserts anull
value into a given property of the health data object. The existing value for the property is replaced.- Parameters:
key
- The health data's specific property name- Since:
- 1.1.0
-
clear
public void clear()
Clears values of all properties in the health data object.- Since:
- 1.0.0
-
-