简体   繁体   English

如何从聊天应用程序中删除任何特定的聊天记录 android firebase

[英]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这是我的 firebase 数据

在此处输入图像描述

To delete a node from the database you call removeValue() on a DatabaseReference to that node.要从数据库中删除一个节点,您可以对该节点的DatabaseReference调用removeValue()

So you can create the entire Chats node with:所以你可以创建整个Chats节点:

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.您将需要知道/指定整个hI151...这段代码中的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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