Deleting data is a key part of the CRUD operations in Health Connect. This guide
shows you how you can delete records in two ways.

> [!TIP]
> **Tip:** For further guidance on deleting data, take a look at the [Android Developer video for reading and writing data](https://www.youtube.com/watch?v=NAx7Gv_Hk7E&t=299) in Health Connect.

## Delete using Record IDs

You can delete records using a list of unique identifiers such as the Record ID
and your app's Client Record ID. Use [`deleteRecords`](https://developer.android.com/reference/kotlin/androidx/health/connect/client/HealthConnectClient.md.txt#deleteRecords(kotlin.reflect.KClass,kotlin.collections.List,kotlin.collections.List)), and
supply it with two lists of `Strings`, one for the Record IDs and one for the
Client IDs. If you only have one of the IDs available, you can set `emptyList()`
on the other list.

The following code example shows how to delete Steps data using its IDs:


```kotlin
try {
    healthConnectClient.deleteRecords(
        recordType = StepsRecord::class,
        recordIdsList = idList,
        clientRecordIdsList = emptyList<String>()
    )
} catch (e: Exception) {
    // Run error handling here
}
```

<br />

## Delete using a time range

You can also delete data using a time range as your filter.
Use [`deleteRecords`](https://developer.android.com/reference/kotlin/androidx/health/connect/client/HealthConnectClient.md.txt#deleteRecords(kotlin.reflect.KClass,androidx.health.connect.client.time.TimeRangeFilter)), and supply it with a
[`TimeRangeFilter`](https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.md.txt) object that takes
a start and end timestamp values.

The following code example shows how to delete Steps data of a specific time:


```kotlin
try {
    healthConnectClient.deleteRecords(
        StepsRecord::class,
        timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
    )
} catch (e: Exception) {
    // Run error handling here
}
```

<br />