Write Blood Glucose Data

Your app can record blood glucose data by writing to the com.google.blood_glucose data type. In this data type, each data point represents a single instantaneous blood glucose reading. The data point contains fields for the blood glucose concentration, temporal relationships to meals and sleep, and the source of the specimen which was measured. All fields except for blood glucose concentration are optional.

To write a blood glucose data point, create a new DataSource of TYPE_BLOOD_GLUCOSE, as shown in the following example.

DataSource bloodGlucoseSource = new DataSource.Builder()

DataPoint bloodGlucose = DataPoint.create(bloodGlucoseSource);
bloodGlucose.setTimestamp(now.getMillis(), MILLISECONDS);
bloodGlucose.getValue(FIELD_BLOOD_GLUCOSE_LEVEL).setFloat(5.0f); // 90 mg/dL