-1

How to delete one entry in a user in the Firebase database?

enter image description here

I don’t remember how to delete these entries! help me, please!

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • See https://firebase.google.com/docs/database/android/read-and-write#delete_data If you're having a hard time making that work, edit your question to show where you got stuck. – Frank van Puffelen Apr 18 '20 at 13:34

2 Answers2

1

Just make sure of changes of id to given id and Another by using uid.

FirebaseDatabase.getInstance().getReference().child("Markers").(id).child(uid).removeValue();
Ashish
  • 6,791
  • 3
  • 26
  • 48
1

To remove that value, you should add to your reference the keys of all nodes. So please use the following lines of code:

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference uidRef = rootRef.child("Markers").child(uid);
uidRef.child("-M5957WblHTL3Eu-1jnE").removeValue().addOnCompleteListener(new OnCompleteListener<Void>() {
    @Override
    public void onComplete(@NonNull Task<Void> task) {
        if (task.isSuccessful()) {
            Log.d("TAG", "Child deleted!");
        } else {
            Log.d("TAG", task.getException().getMessage());
    }
});
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • tell me! is it possible to get the line: .child ("- M5957WblHTL3Eu-1jnE") and the rest, get programmatically? – user3711927 Apr 19 '20 at 12:15
  • Yes, it is possible. Check **[this](https://stackoverflow.com/questions/51787784/how-to-get-specific-pushedid-in-firebase/51788244)** out. – Alex Mamo Apr 20 '20 at 07:52