In Firebase RealtimeDatabase, I'm saving chats in "Chats" reference like that:
"Chats" : { "-Ma83vy-1hjQ8nJ6LgTM" : { "isseen" : true, "message" : "Go", "messageTime" : "14:20", "receiver" : "to", "sender" : "from" }, "-Ma845xcxQjN5IlhpaPV" : { "isseen" : true, "message" : "Hi", "messageTime" : "14:21", "receiver" : "to", "sender" : "whom" },
WHen I want delete a specific chat, I need to obtain this: Ma83vy-1hjQ8nJ6LgTM or this Ma83vy1hjQ8nJ6LgTM. But I don't know how to get this.
This is how I save chats in database:
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("sender", sender);
hashMap.put("receiver", receiver);
hashMap.put("message", message);
hashMap.put("messageTime", time);
hashMap.put("isseen", false);
reference.child("Chats").push().setValue(hashMap);
So how can get these headers : Ma83vy-1hjQ8nJ6LgTM or Ma845xcxQjN5IlhpaPV Or is there any other way of deleting a specific data ?