Q:

DataSet Object for the Google Fit API

Working with the Google Fit API at the moment and having a bit of trouble with the Sessions API. I'm trying to insert a session for my app's workouts but the documentation is a bit confusing.
In this code snippet is an example from Google's info page. Where exactly do you get DataSet objects from and/or how do you create them from existing data?﻿
    // Create a session with metadata about the activity.
    Session session = new Session.Builder()
            .setName(SAMPLE_SESSION_NAME)
            .setDescription("Long run around Shoreline Park")
            .setIdentifier("UniqueIdentifierHere")
            .setActivity(FitnessActivities.RUNNING)
            .setStartTime(startTime, TimeUnit.MILLISECONDS)
            .setEndTime(endTime, TimeUnit.MILLISECONDS)
            .build();

    // Build a session insert request
    SessionInsertRequest insertRequest = new SessionInsertRequest.Builder()
            .setSession(session)
            .addDataSet(runningDataSet)  //where does this come from???
            .build();

Here is a link to Google Sessions API page (which is what I'm using for this code):
Google Fit API (Sessions API)

A:

A DataSet comes from a DataSource, so you will have to create a DataSource first, then simply DataSet.create(yourDataSource);
For example:
  DataSource dataSource = new DataSource.Builder()
                .setType(DataSource.TYPE_RAW)
                .setDataType(exerciseDataType)
                .setName(exercise.name)
                .setAppPackageName(this)
                .build();

  DataSet dataSet = DataSet.create(dataSource);

  ...

  dataSet.createDataPoint()....insert values :-)

