I am working on an application where i have implemented the chats in my application. So i want to know that how can i delete a whole chat like suppose I have sent a message to someone or someone sent a message to me so how can i delete that particular chat
this is the image
in the image above are tha chats with whom i have interacted. so if i want to delete any chat out of these how can i do that??
this is the my firebase data
CodePudding user response:
To delete a node from the database you call removeValue()
on a DatabaseReference
to that node.
So you can create the entire Chats
node with:
DatabaseReference root = FirebaseDatabase.getInstance().getReference();
root.child("Chats").removeValue();
To delete a lower-level node, you can specify the entire path to that node:
root.child("Chats/hI151.../messages").removeValue();
You will need to know/specify the entire hI151...
value in this code.