# Class HealthDeleteRequest

java.lang.Object
com.codename1.health.HealthDeleteRequest

public final class HealthDeleteRequest extends Object

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.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `HealthDeleteRequest`
  `addType(HealthDataType type)`
  Adds another type to a range-based request.
  `static HealthDeleteRequest`
  `byId(HealthDataType type, String sampleId)`
  Deletes one sample of `type` by its platform identifier.
  `static HealthDeleteRequest`
  `byIds(HealthDataType type, List<String> sampleIds)`
  Deletes specific samples of `type` by their platform identifiers.
  `static HealthDeleteRequest`
  `byRange(HealthDataType type, HealthTimeRange range)`
  Deletes everything of `type` that this app wrote inside `range`.
  `List<String>`
  `getSampleIds()`
  The identifiers to delete, empty for a range-based request.
  `HealthTimeRange`
  `getTimeRange()`
  The span to delete within, null for an identifier-based request.
  `List<HealthDataType>`
  `getTypes()`
  The types to delete, empty for an identifier-based request.
  `boolean`
  `isById()`
  `true` when this request names specific samples rather than a span.
  `void`
  `validate()`
  Validates the request.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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)
    Deletes one sample of `type` by its platform identifier.

  - ### byRange

    public static HealthDeleteRequest byRange(HealthDataType type, HealthTimeRange range)
    Deletes everything of `type` that this app wrote inside `range`.

  - ### addType

    public HealthDeleteRequest addType(HealthDataType type)
    Adds another type to a range-based request.

  - ### getSampleIds

    public List<String> getSampleIds()
    The identifiers to delete, empty for a range-based request.

  - ### getTypes

    public List<HealthDataType> getTypes()
    The types to delete, empty for an identifier-based request.

  - ### getTimeRange

    public HealthTimeRange getTimeRange()
    The span to delete within, null for an identifier-based request.

  - ### isById

    public boolean isById()
    `true` when this request names specific samples rather than a span.

  - ### validate

    public void validate() throws HealthException

    Validates the request.

    ###### Throws

    - `HealthException`: `HealthError.INVALID_ARGUMENT` when the request names neither identifiers nor a type and range, or ambiguously names both.
    Throws:
      `HealthException`