Added in API level 34

Builder

class Builder<T : Record!>
kotlin.Any
   ↳ android.health.connect.ReadRecordsRequestUsingFilters.Builder

Builder class for ReadRecordsRequestUsingFilters

Summary

Public constructors
Builder(recordType: Class<T>)

Public methods
ReadRecordsRequestUsingFilters.Builder<T>

Sets the data origin filter based on which the read operation is to be performed

ReadRecordsRequestUsingFilters<T>

Returns an Object of ReadRecordsRequestUsingFilters

ReadRecordsRequestUsingFilters.Builder<T>
setAscending(ascending: Boolean)

Sets ordering of results to be returned based on start time.

ReadRecordsRequestUsingFilters.Builder<T>
setPageSize(pageSize: Int)

Sets maximum number of records to be returned by the read operation

ReadRecordsRequestUsingFilters.Builder<T>
setPageToken(pageToken: Long)

Sets page token to read the requested page of the result.

ReadRecordsRequestUsingFilters.Builder<T>

Sets time range b/w which the read operation is to be performed

Public constructors

Builder

Added in API level 34
Builder(recordType: Class<T>)
Parameters
recordType Class<T>: Class object of Record type that needs to be read This value cannot be null.

Public methods

addDataOrigins

Added in API level 34
fun addDataOrigins(dataOrigin: DataOrigin): ReadRecordsRequestUsingFilters.Builder<T>

Sets the data origin filter based on which the read operation is to be performed

Parameters
dataOrigin DataOrigin: Adds DataOrigin for which to read records.

If no DataOrigin is added then records by all DataOrigins will be read This value cannot be null.

Return
ReadRecordsRequestUsingFilters.Builder<T> This value cannot be null.

build

Added in API level 34
fun build(): ReadRecordsRequestUsingFilters<T>

Returns an Object of ReadRecordsRequestUsingFilters

For subsequent read requests, ReadRecordsRequestUsingFilters does not allow both pageToken and sort order to be set together.

If pageToken is set then records will be sorted in same order as the previous result

If both pageToken and sortOrder are not set then by default records will be sorted by start time in ascending order.

Return
ReadRecordsRequestUsingFilters<T> This value cannot be null.
Exceptions
java.lang.IllegalStateException if both pageToken and sort order is set.

setAscending

Added in API level 34
fun setAscending(ascending: Boolean): ReadRecordsRequestUsingFilters.Builder<T>

Sets ordering of results to be returned based on start time. Ordering cannot be set along with page token for subsequent requests. IllegalState exception is thrown when ordering is set along with the page token.

Parameters
ascending Boolean: specifies sorting order of results, if set to true records are sorted on start time in ascending fashion, else if set to false then in descending.
Return
ReadRecordsRequestUsingFilters.Builder<T> This value cannot be null.

setPageSize

Added in API level 34
fun setPageSize(pageSize: Int): ReadRecordsRequestUsingFilters.Builder<T>

Sets maximum number of records to be returned by the read operation

Parameters
pageSize Int: number of records to be returned by the read operation.

This sets to limit number of rows returned by a read. If not set default is 1000 and maximum of 5000 records can be sent. Value is between 1 and 5000 inclusive

Return
ReadRecordsRequestUsingFilters.Builder<T> This value cannot be null.

setPageToken

Added in API level 34
fun setPageToken(pageToken: Long): ReadRecordsRequestUsingFilters.Builder<T>

Sets page token to read the requested page of the result.

Parameters
pageToken Long: to read the requested page of the result. -1 if none available
Return
ReadRecordsRequestUsingFilters.Builder<T> This value cannot be null.

setTimeRangeFilter

Added in API level 34
fun setTimeRangeFilter(timeRangeFilter: TimeRangeFilter?): ReadRecordsRequestUsingFilters.Builder<T>

Sets time range b/w which the read operation is to be performed

Parameters
timeRangeFilter TimeRangeFilter?: Time range b/w which the read operation is to be performed.

If not time range filter is present all the records will be read without any time constraints. This value may be null.

Return
ReadRecordsRequestUsingFilters.Builder<T> This value cannot be null.