public final class Metadata


Set of shared metadata fields for Record.

Summary

Constants

static final int

For actively recorded data by the user.

static final int

For passively recorded data by the app.

static final int

For manually entered data by the user.

static final int

Unknown recording method.

Public constructors

Metadata(
    @NonNull String id,
    @NonNull DataOrigin dataOrigin,
    @NonNull Instant lastModifiedTime,
    String clientRecordId,
    long clientRecordVersion,
    Device device,
    int recordingMethod
)

Public methods

boolean
equals(Object other)
final String

Optional client supplied record unique data identifier associated with the data.

final long

Optional client supplied version associated with the data.

final @NonNull DataOrigin

Where the data comes from, such as application information originally generated this data.

final Device

Optional client supplied device information associated with the data.

final @NonNull String

Unique identifier of this data, assigned by the Android Health Platform at insertion time.

final @NonNull Instant

Automatically populated to when data was last modified (or originally created).

final int

Optional client supplied data recording method to help to understand how the data was recorded.

int
@NonNull String

Constants

RECORDING_METHOD_ACTIVELY_RECORDED

public static final int RECORDING_METHOD_ACTIVELY_RECORDED = 1

For actively recorded data by the user.

For e.g. An exercise session actively recorded by the user using a phone or a watch device.

RECORDING_METHOD_AUTOMATICALLY_RECORDED

public static final int RECORDING_METHOD_AUTOMATICALLY_RECORDED = 2

For passively recorded data by the app.

For e.g. Steps data recorded by a watch or phone without the user starting a session.

RECORDING_METHOD_MANUAL_ENTRY

public static final int RECORDING_METHOD_MANUAL_ENTRY = 3

For manually entered data by the user.

For e.g. Nutrition or weight data entered by the user.

RECORDING_METHOD_UNKNOWN

public static final int RECORDING_METHOD_UNKNOWN = 0

Unknown recording method.

Public constructors

Metadata

Added in 1.1.0-alpha10
public Metadata(
    @NonNull String id,
    @NonNull DataOrigin dataOrigin,
    @NonNull Instant lastModifiedTime,
    String clientRecordId,
    long clientRecordVersion,
    Device device,
    int recordingMethod
)

Public methods

equals

public boolean equals(Object other)

getClientRecordId

Added in 1.1.0-alpha10
public final String getClientRecordId()

Optional client supplied record unique data identifier associated with the data.

There is guaranteed a single entry for any type of data with same client provided identifier for a given client. Any new insertions with the same client provided identifier will either replace or be ignored depending on associated clientRecordVersion.

getClientRecordVersion

Added in 1.1.0-alpha10
public final long getClientRecordVersion()

Optional client supplied version associated with the data.

This determines conflict resolution outcome when there are multiple insertions of the same clientRecordId. Data with the highest clientRecordVersion takes precedence. clientRecordVersion starts with 0.

See also
clientRecordId

getDataOrigin

Added in 1.1.0-alpha10
public final @NonNull DataOrigin getDataOrigin()

Where the data comes from, such as application information originally generated this data. When Record is created before insertion, this contains a sentinel value, any assigned value will be ignored. After insertion, this will be populated with inserted application.

getDevice

Added in 1.1.0-alpha10
public final Device getDevice()

Optional client supplied device information associated with the data.

getId

Added in 1.1.0-alpha10
public final @NonNull String getId()

Unique identifier of this data, assigned by the Android Health Platform at insertion time. When Record is created before insertion, this takes a sentinel value, any assigned value will be ignored.

getLastModifiedTime

Added in 1.1.0-alpha10
public final @NonNull Instant getLastModifiedTime()

Automatically populated to when data was last modified (or originally created). When Record is created before inserted, this contains a sentinel value, any assigned value will be ignored.

getRecordingMethod

Added in 1.1.0-alpha10
public final int getRecordingMethod()

Optional client supplied data recording method to help to understand how the data was recorded.

It should be one of the following: RECORDING_METHOD_UNKNOWN, RECORDING_METHOD_ACTIVELY_RECORDED, RECORDING_METHOD_AUTOMATICALLY_RECORDED and RECORDING_METHOD_MANUAL_ENTRY.

hashCode

public int hashCode()

toString

public @NonNull String toString()