Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class HealthDeleteRequest
- Object
- HealthDeleteRequest
Describes what to delete from HealthStore, either by identifier or
by type and time range.
You can only delete your own data
Both platforms restrict deletion to samples your app wrote. A request covering another app’s data silently deletes nothing rather than failing, which is a deliberate platform choice: an app must not be able to discover what other apps recorded by watching which deletes succeed.
Methods
public static HealthDeleteRequest byIds(HealthDataType type, List<String> sampleIds) | Deletes specific samples of type by their platform identifiers. |
public static HealthDeleteRequest byId(HealthDataType type, String sampleId) | Deletes one sample of type by its platform identifier. |
public static HealthDeleteRequest byRange(HealthDataType type, HealthTimeRange range) | Deletes everything of type that this app wrote inside range. |
public HealthDeleteRequest addType(HealthDataType type) | Adds another type to a range-based request. |
public List<String> getSampleIds() | The identifiers to delete, empty for a range-based request. |
public List<HealthDataType> getTypes() | The types to delete, empty for an identifier-based request. |
public HealthTimeRange getTimeRange() | The span to delete within, null for an identifier-based request. |
public boolean isById() | true when this request names specific samples rather than a span. |
public void validate()
throws HealthException | Validates the request. |
Inherited methods
Method details
byIds
public static HealthDeleteRequest byIds(HealthDataType type, List<String> sampleIds)Deletes specific samples of type by their platform identifiers.
The type is required, not redundant: Health Connect deletes by record class plus id and cannot resolve an id on its own, so a request without one could only be honoured by guessing. Asking for it here means the caller states what they are deleting rather than the platform silently deleting nothing.
byId
public static HealthDeleteRequest byId(HealthDataType type, String sampleId)type by its platform identifier.byRange
public static HealthDeleteRequest byRange(HealthDataType type, HealthTimeRange range)type that this app wrote inside range.addType
public HealthDeleteRequest addType(HealthDataType type)getSampleIds
public List<String> getSampleIds()getTypes
public List<HealthDataType> getTypes()getTimeRange
public HealthTimeRange getTimeRange()isById
public boolean isById()true when this request names specific samples rather than a span.validate
public void validate()
throws HealthExceptionThrows
HealthExceptionHealthError.INVALID_ARGUMENTwhen the request names neither identifiers nor a type and range, or ambiguously names both.