DataSet | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Analyze
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public final class

# DataSet

extends Object
implements Parcelable

java.lang.Object
↳ | com.google.android.gms.fitness.data.DataSet

## Class Overview

Represents a fixed set of `data points` in a `data type's` stream from a particular `data source`. A data set usually represents data at fixed time boundaries, and can be used both for batch data insertion and as a result of read requests.

Here's a sample usage for populating a data source with activity data:

         DataType dataType = DataTypes.ACTIVITY_SEGMENT;
         DataSet dataSet = DataSet.create(dataSource);
         for (ActivitySegment segment : getActivitySegments()) {
           dataSet.add(dataSet.createDataPoint()
               .setTimeInterval(segment.getStartMillis(), segment.getEndTimeMillis(), MILLISECONDS))
               .setValues(segment.getActivity()));
         }

## Summary

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final Creator<DataSet> | CREATOR |

Public Methods
void | add(DataPoint dataPoint) Adds a data point to this data set.
void | addAll(Iterable<DataPoint> dataPoints) Adds a list of data points to this data set in bulk.
static DataSet | create(DataSource dataSource) Creates a new data set to hold data points for the given `dataSource`.
DataPoint | createDataPoint() Creates an empty data point for this data set's data source.
int | describeContents()
boolean | equals(Object o)
List<DataPoint> | getDataPoints() Returns the list of data points represented by this data set.
DataSource | getDataSource() Returns the data source which this data set represents.
DataType | getDataType() Returns the data type this data set represents.
int | hashCode()
String | toString()
void | writeToParcel(Parcel parcel, int flags)

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Fields

#### public static final Creator<DataSet> CREATOR

## Public Methods

#### public void add (DataPoint dataPoint)

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.

#### public void addAll (Iterable<DataPoint> dataPoints)

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.

#### public static DataSet create (DataSource dataSource)

Creates a new data set to hold data points for the given `dataSource`.

Data points with the matching data source can be created using `createDataPoint()`, and after having the values set added to the data set via `add(DataPoint)`.

##### Throws

NullPointerException | if specified data source is null

#### public DataPoint createDataPoint ()

Creates an empty data point for this data set's data source. The new data point is not added to the data set by this method. After the data point is initialized, `add(DataPoint)` should be called.

#### public int describeContents ()

#### public boolean equals (Object o)

#### public List<DataPoint> getDataPoints ()

Returns the list of data points represented by this data set. The data points will preserve the same order in which they were inserted.

Certain APIs that return a DataSet might insert data points in chronological order, but this isn't enforced.

#### public DataSource getDataSource ()

Returns the data source which this data set represents. All of the data points in the data set are from this data source.

#### public DataType getDataType ()

Returns the data type this data set represents. All of the data points in the data set are of this data type.

#### public int hashCode ()

#### public String toString ()

#### public void writeToParcel (Parcel parcel, int flags)