简体   繁体   中英

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

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

在此处输入图像描述

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM