Health Connect throws standard exceptions for CRUD operations when an issue is encountered, and all apps should ensure that these are appropriately caught and handled.
Each method on
HealthConnectClient lists the exceptions that can be thrown, but in general, the following should be handled:
SecurityException- where the request would require permissions that are not currently granted.
IOException- where issues are encountered reading and writing from disk.
IllegalStateException- where the Health Connect service is not available, or where the request is not a valid construction. E.g. a read request where the
startTimeis after the
RemoteException- where errors occur in, or in communicating with, the underlying service to which the SDK connects. For example, this could include trying to delete a record with a given
uid: Only after checking in the underlying service is it known that the record does not exist.