[英]Android Studio Firebase updateChildren
Good day everyone. 今天是个好日子。 I'm having hard time time in Android Studio and Firebase, whenever I try to use updateChildren, it keeps on replacing the old one.
我在Android Studio和Firebase中度过了艰难的时光,每当我尝试使用updateChildren时,它都会继续替换旧的。 I thought it would remain the old data inside the node, here is the code:
我以为它将旧数据保留在节点内,这是代码:
private void getClosestDriver() {
DatabaseReference driverLocation = FirebaseDatabase.getInstance().getReference().child("driversAvailable");
GeoFire geoFire = new GeoFire(driverLocation);
geoQuery = geoFire.queryAtLocation(new GeoLocation(pickupLocation.latitude, pickupLocation.longitude), radius);
geoQuery.removeAllListeners();
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
@Override
public void onKeyEntered(String key, GeoLocation location) {
if (!driverFound && requestBol) {
driverFound = true;
driverFoundID = key;
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Users").child("Driver").child(driverFoundID).child("passengerRequest");
String passengerID = FirebaseAuth.getInstance().getCurrentUser().getUid();
HashMap map = new HashMap();
map.put("passengerRideID", passengerID);
map.put("destination", destination);
ref.updateChildren(map);
getDriverLocation();
mRequest.setText("Looking for Bus Location....");
}
}
Am I doing the right thing about the HasMap? 我是否对HasMap做正确的事情?
by changing it into 通过将其更改为
String passengerID = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Users").child("Driver").child(driverFoundID).child("passengerRequest").child(passengerID);
HashMap map = new HashMap();
map.put("destination", destination);
ref.updateChildren(map);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.