Home > Net >  How to delete the any particular chats from the chat application android firebase
How to delete the any particular chats from the chat application android firebase

Time:11-15

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

enter image description here

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

enter image description here

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.

  • Related