不是将表驱动程序
的子项的数据设置为null
..我想要那个特定的子项
将被删除。
这是我的示例代码。
driverRef = new Firebase(Config.FIREBASE_URL_DRIVER);
Query pendingBus = driverRef.orderByChild("busNum").equalTo(busNum);
pendingBus.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
String busnumber = snapshot.child("busNum").getValue().toString();
String empID = snapshot.child("empId").getValue().toString();
if (busnumber.equals(busNum)) {
snapshot.getRef().child("age").setValue("");
snapshot.getRef().child("busNum").setValue("");
snapshot.getRef().child("driversName").setValue("");
snapshot.getRef().child("empId").setValue("");
snapshot.getRef().child("latitude").setValue("");
snapshot.getRef().child("longitude").setValue("");
snapshot.getRef().child("password").setValue("");
snapshot.getRef().child("username").setValue("");
}
}
最佳答案
而不是使用 setValue
到 null
我使用 .removeValue
示例:snapshot.getRef().child("age").removeValue();
关于android - 如何在 Firebase (Android) 中删除特定的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39553491/