# HealthConnectClientExt

Added in 1.1.0

*** ** * ** ***


```
public final class HealthConnectClientExt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record> https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClientExt#(androidx.health.connect.client.HealthConnectClient).deleteRecords(androidx.health.connect.client.time.TimeRangeFilter)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter timeRangeFilter )` Deletes any `https://developer.android.com/reference/androidx/health/connect/client/records/Record` of type `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).deleteRecords(androidx.health.connect.client.time.TimeRangeFilter)` in the given `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).deleteRecords(androidx.health.connect.client.time.TimeRangeFilter)` (automatically filtered to `https://developer.android.com/reference/androidx/health/connect/client/records/Record` belonging to the calling application). |
| `static final void` | `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record> https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClientExt#(androidx.health.connect.client.HealthConnectClient).deleteRecords(kotlin.collections.List,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> recordIdsList, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> clientRecordIdsList )` Deletes one or more `https://developer.android.com/reference/androidx/health/connect/client/records/Record` by their identifiers. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/response/ReadRecordResponse<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record> https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClientExt#(androidx.health.connect.client.HealthConnectClient).readRecord(kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html recordId )` Reads one `https://developer.android.com/reference/androidx/health/connect/client/records/Record` point of type `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).readRecord(kotlin.String)` and with the specified `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).readRecord(kotlin.String)`. |

## Public methods

### deleteRecords

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/HealthConnectClientExt.kt+function:deleteRecords)

```
public static final void <T extends Record> deleteRecords(
    @NonNull HealthConnectClient receiver,
    @NonNull TimeRangeFilter timeRangeFilter
)
```

Deletes any `https://developer.android.com/reference/androidx/health/connect/client/records/Record` of type `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).deleteRecords(androidx.health.connect.client.time.TimeRangeFilter)` in the given `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).deleteRecords(androidx.health.connect.client.time.TimeRangeFilter)` (automatically filtered to `https://developer.android.com/reference/androidx/health/connect/client/records/Record` belonging to the calling application). Deletion of multiple `https://developer.android.com/reference/androidx/health/connect/client/records/Record` is executed in a transaction - if one fails, none is deleted.

```kotlin
import androidx.health.connect.client.deleteRecords
import androidx.health.connect.client.records.StepsRecord
import androidx.health.connect.client.time.TimeRangeFilter

healthConnectClient.deleteRecords<StepsRecord>(
    timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
)
```

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record>` | Which type of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to delete, such as `StepsRecord`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter timeRangeFilter` | The `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` to delete from |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | For any IPC transportation failures. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | For requests with unpermitted access. |
| `https://developer.android.com/reference/java/io/IOException.html` | For any disk I/O issues. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If service is not available. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient#deleteRecords(kotlin.reflect.KClass,kotlin.collections.List,kotlin.collections.List)` | Example usage to delete written steps data in a time range: |

### deleteRecords

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/HealthConnectClientExt.kt+function:deleteRecords)

```
public static final void <T extends Record> deleteRecords(
    @NonNull HealthConnectClient receiver,
    @NonNull List<@NonNull String> recordIdsList,
    @NonNull List<@NonNull String> clientRecordIdsList
)
```

Deletes one or more `https://developer.android.com/reference/androidx/health/connect/client/records/Record` by their identifiers. Deletion of multiple `https://developer.android.com/reference/androidx/health/connect/client/records/Record` is executed in single transaction - if one fails, none is deleted.

```kotlin
import androidx.health.connect.client.deleteRecords
import androidx.health.connect.client.records.StepsRecord

healthConnectClient.deleteRecords<StepsRecord>(
    recordIdsList = listOf(uid1, uid2),
    clientRecordIdsList = emptyList(),
)
```

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record>` | Which type of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to delete, such as `StepsRecord`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> recordIdsList` | List of `https://developer.android.com/reference/androidx/health/connect/client/records/metadata/Metadata#id()` of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to delete |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> clientRecordIdsList` | List of client record IDs of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to delete |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | For any IPC transportation failures. Deleting by invalid identifiers such as a non-existing identifier or deleting the same record multiple times will result in IPC failure. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | For requests with unpermitted access. |
| `https://developer.android.com/reference/java/io/IOException.html` | For any disk I/O issues. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If service is not available. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient#deleteRecords(kotlin.reflect.KClass,kotlin.collections.List,kotlin.collections.List)` | Example usage to delete written steps data by its unique identifier: |

### readRecord

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/HealthConnectClientExt.kt+function:readRecord)

```
public static final @NonNull ReadRecordResponse<@NonNull T> <T extends Record> readRecord(
    @NonNull HealthConnectClient receiver,
    @NonNull String recordId
)
```

Reads one `https://developer.android.com/reference/androidx/health/connect/client/records/Record` point of type `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).readRecord(kotlin.String)` and with the specified `https://developer.android.com/reference/androidx/health/connect/client/package-summary#(androidx.health.connect.client.HealthConnectClient).readRecord(kotlin.String)`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/health/connect/client/records/Record>` | Which type of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to read, such as `StepsRecord`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html recordId` | `https://developer.android.com/reference/androidx/health/connect/client/records/metadata/Metadata#id()` of `https://developer.android.com/reference/androidx/health/connect/client/records/Record` to read |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/response/ReadRecordResponse<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | The `https://developer.android.com/reference/androidx/health/connect/client/records/Record` data point. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | For any IPC transportation failures. Update with invalid identifiers will result in IPC failure. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | For requests with unpermitted access. |
| `https://developer.android.com/reference/java/io/IOException.html` | For any disk I/O issues. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If service is not available. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient#readRecord(kotlin.reflect.KClass,kotlin.String)` |   |