DataSet.Builder
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From class java.lang.Object
Public Methods
Adds a data point to this data set. The data points should be for the correct data
type and data source, and should have its timestamp already set.
Throws
If dataPoint
has the wrong DataSource
,
or contain invalid data.
Adds a list of data points to this data set in bulk. All data points should be for
the correct data type and data source, and should have their timestamp already set.
Throws
If the dataPoints
have the wrong source, or contain invalid
data.
public DataSet
build
()
Finishes building and returns the DataSet
.
Throws
If called more than once.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eDataSet.Builder\u003c/code\u003e is used to create new \u003ccode\u003eDataSet\u003c/code\u003e objects for fitness data.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to add individual (\u003ccode\u003eadd()\u003c/code\u003e) or multiple (\u003ccode\u003eaddAll()\u003c/code\u003e) data points to the \u003ccode\u003eDataSet\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eData points added should have the correct data type, data source, and timestamp.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method finalizes the \u003ccode\u003eDataSet\u003c/code\u003e creation and returns the \u003ccode\u003eDataSet\u003c/code\u003e object.\u003c/p\u003e\n"]]],[],null,["# DataSet.Builder\n\npublic static class **DataSet.Builder** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nBuilder used to create new [data\nsets](/android/reference/com/google/android/gms/fitness/data/DataSet). \n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [DataSet.Builder](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder) | [add](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder#add(com.google.android.gms.fitness.data.DataPoint))([DataPoint](/android/reference/com/google/android/gms/fitness/data/DataPoint) dataPoint) Adds a data point to this data set. |\n| [DataSet.Builder](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder) | [addAll](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder#addAll(java.lang.Iterable\u003ccom.google.android.gms.fitness.data.DataPoint\u003e))([Iterable](//developer.android.com/reference/java/lang/Iterable.html)\\\u003c[DataPoint](/android/reference/com/google/android/gms/fitness/data/DataPoint)\\\u003e dataPoints) Adds a list of data points to this data set in bulk. |\n| [DataSet](/android/reference/com/google/android/gms/fitness/data/DataSet) | [build](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder#build())() Finishes building and returns the [DataSet](/android/reference/com/google/android/gms/fitness/data/DataSet). |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public [DataSet.Builder](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder)\n**add** ([DataPoint](/android/reference/com/google/android/gms/fitness/data/DataPoint) dataPoint)\n\nAdds a data point to this data set. The data points should be for the correct data\ntype and data source, and should have its timestamp already set. \n\n##### Throws\n\n| [IllegalArgumentException](//developer.android.com/reference/java/lang/IllegalArgumentException.html) | If `dataPoint` has the wrong [DataSource](/android/reference/com/google/android/gms/fitness/data/DataSource), or contain invalid data. |\n|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public [DataSet.Builder](/android/reference/com/google/android/gms/fitness/data/DataSet.Builder)\n**addAll** ([Iterable](//developer.android.com/reference/java/lang/Iterable.html)\\\u003c[DataPoint](/android/reference/com/google/android/gms/fitness/data/DataPoint)\\\u003e dataPoints)\n\nAdds a list of data points to this data set in bulk. All data points should be for\nthe correct data type and data source, and should have their timestamp already set. \n\n##### Throws\n\n| [IllegalArgumentException](//developer.android.com/reference/java/lang/IllegalArgumentException.html) | If the `dataPoints` have the wrong source, or contain invalid data. |\n|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|\n\n#### public [DataSet](/android/reference/com/google/android/gms/fitness/data/DataSet)\n**build** ()\n\nFinishes building and returns the [DataSet](/android/reference/com/google/android/gms/fitness/data/DataSet). \n\n##### Throws\n\n| [IllegalStateException](//developer.android.com/reference/java/lang/IllegalStateException.html) | If called more than once. |\n|-------------------------------------------------------------------------------------------------|---------------------------|"]]