How to delete from firebase realtime database?

Solution 1:

If you don't know the key of the items to remove, you will first need to query the database to determine those keys:

DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
Query applesQuery = ref.child("firebase-test").orderByChild("title").equalTo("Apple");

applesQuery.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot appleSnapshot: dataSnapshot.getChildren()) {
            appleSnapshot.getRef().removeValue();
        }
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {
        Log.e(TAG, "onCancelled", databaseError.toException());
    }
});

Solution 2:

this solved my problem

 mPostReference = FirebaseDatabase.getInstance().getReference()
                        .child("quotes").child(mPostKey);
                mPostReference.removeValue();