Nutrition
NutritionRecord in Health Connect. Check what the API exposes and what to look for when this data is missing or differs between apps.
API contract
- Identifier
NutritionRecord- Time shape
- Interval
- Documented unit or dimension
- Mass
- Required record fields
endTimemealTypemetadatastartTime
Read a known time window
Run this inside a coroutine with an initialized Health Connect client, a start and end instant, and the required read grant. Follow the next-page token when checking a larger time range.
val page = healthConnectClient.readRecords(
ReadRecordsRequest(
NutritionRecord::class,
timeRangeFilter = TimeRangeFilter.between(start, end)
)
)
val records = page.recordsRead and paginate Health Connect records
Manifest permissions in the Android documentation
android.permission.health.READ_NUTRITIONandroid.permission.health.WRITE_NUTRITION
Aggregate metrics (42)
NutritionRecord.BIOTIN_TOTALNutritionRecord.CAFFEINE_TOTALNutritionRecord.CALCIUM_TOTALNutritionRecord.CHLORIDE_TOTALNutritionRecord.CHOLESTEROL_TOTALNutritionRecord.CHROMIUM_TOTALNutritionRecord.COPPER_TOTALNutritionRecord.DIETARY_FIBER_TOTALNutritionRecord.ENERGY_FROM_FAT_TOTALNutritionRecord.ENERGY_TOTALNutritionRecord.FOLATE_TOTALNutritionRecord.FOLIC_ACID_TOTALNutritionRecord.IODINE_TOTALNutritionRecord.IRON_TOTALNutritionRecord.MAGNESIUM_TOTALNutritionRecord.MANGANESE_TOTALNutritionRecord.MOLYBDENUM_TOTALNutritionRecord.MONOUNSATURATED_FAT_TOTALNutritionRecord.NIACIN_TOTALNutritionRecord.PANTOTHENIC_ACID_TOTALNutritionRecord.PHOSPHORUS_TOTALNutritionRecord.POLYUNSATURATED_FAT_TOTALNutritionRecord.POTASSIUM_TOTALNutritionRecord.PROTEIN_TOTALNutritionRecord.RIBOFLAVIN_TOTALNutritionRecord.SATURATED_FAT_TOTALNutritionRecord.SELENIUM_TOTALNutritionRecord.SODIUM_TOTALNutritionRecord.SUGAR_TOTALNutritionRecord.THIAMIN_TOTALNutritionRecord.TOTAL_CARBOHYDRATE_TOTALNutritionRecord.TOTAL_FAT_TOTALNutritionRecord.TRANS_FAT_TOTALNutritionRecord.UNSATURATED_FAT_TOTALNutritionRecord.VITAMIN_A_TOTALNutritionRecord.VITAMIN_B12_TOTALNutritionRecord.VITAMIN_B6_TOTALNutritionRecord.VITAMIN_C_TOTALNutritionRecord.VITAMIN_D_TOTALNutritionRecord.VITAMIN_E_TOTALNutritionRecord.VITAMIN_K_TOTALNutritionRecord.ZINC_TOTAL
What to check when the value is missing
Check that the writing app saved a interval record under NutritionRecord and that the reading app has access to it. Start with a recent interval that contains a known record.
For a synthetic record, inspect mealType before comparing it with what the reader displays.
Compare the data origin and timestamp before looking at a daily dashboard. Check which of the listed metrics the app uses and which sources contribute to it.
Compare with Apple HealthKit
Dietary Protein dietaryProtein
Android can store multiple nutrients together. The Apple protein identifier stores an individual quantity. Keep the unit and timestamp and retain meal context separately if the writer provides it.
Dietary Energy Consumed dietaryEnergyConsumed
Android nutrition can bundle energy and nutrients. The Apple energy identifier stands on its own. Compare consumed energy independently of workout or resting energy.
Dietary Caffeine dietaryCaffeine
Health Connect can store caffeine among other meal fields. HealthKit treats it as its own quantity. Keep original source and units when converting to a common display.
More in Nutrition
API documentation checked . Examples are developer starting points based on the published API.