I'm making an app that periodically uploads your step data to Firestore for tracking purposes, and I add all the step data with date:steps in key:value pairs of a hashmap, but for some reason, each individual key:value pair goes into a nested map as value with the key as some arbitrary number. I can't figure out why this is happening. Here's the code:
val stepMap = HashMap<String, String>()
for (dp in dataSet.dataPoints) {
Log.i(TAG,"Data point:")
Log.i(TAG,"\tType: ${dp.dataType.name}")
Log.i(TAG,"\tStart: ${dp.getStartTimeString()}")
Log.i(TAG,"\tEnd: ${dp.getEndTimeString()}")
for (field in dp.dataType.fields) {
Log.i(TAG,"\tField: ${field.name.toString()} Value: ${dp.getValue(field)}")
stepMap.put("${dp.getStartTimeString()}", "${dp.getValue(field)}")
}
}
db.collection("users")
.document(""+GoogleSignIn.getLastSignedInAccount(this).email)
.update(LocalDateTime.now().toString(), stepMap)
This is what the data looks like on Firestore:
I need it to look like this: what it should look like