如何将push()添加到航点儿童?无法做到正确..
Map mWaypoints = new HashMap();
mWaypoints.put("latitude", mCurrentLatlngOnCreate.latitude);
mWaypoints.put("longitude", mCurrentLatlngOnCreate.longitude);
Map mParent = new HashMap();
mParent.put("routeID", "my route id");
mParent.put("routeName", "my route name");
mParent.put("Waypoints", mWaypoints);
myFirebaseRef.push().setValue(mParent);
Run Code Online (Sandbox Code Playgroud)
这是当前结果,但希望将推送ID设置在Waypoints之下.
-KGNWnjgXPC0kHYiOKG7
Waypoints // <--- Want to get the unique below here
latitude: 31
longitude: 421
routeID: "my route id"
routeName: "my route name"
Run Code Online (Sandbox Code Playgroud)
push()是一个纯客户端操作,您可以单独调用.所以:
Map mWaypoints = new HashMap();
mWaypoints.put("latitude", mCurrentLatlngOnCreate.latitude);
mWaypoints.put("longitude", mCurrentLatlngOnCreate.longitude);
String key = myFirebaseRef.push().getKey();
Map mWayPointsMap = new HashMap();
mWayPointsMap.put(key, mWayPoints);
Map mParent = new HashMap();
mParent.put("routeID", "my route id");
mParent.put("routeName", "my route name");
mParent.put("Waypoints", mWayPointsMap);
myFirebaseRef.push().setValue(mParent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5520 次 |
| 最近记录: |