I want to delete the particular child of a child in firebase realtime database.
I have added a picture of my database.
I want to remove the highlighted child.
You can try this code.
Query query = myRef.child("Purchase_Request").orderByChild("Chimney_Purchase");
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snap: dataSnapshot.getChildren()) {
if(snap.getKey().equals("your_key")) {
snap.getRef().removeValue();
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e(TAG, "onCancelled", databaseError.toException());
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.