I'm get the key like that but this did not work I want to delete one item if click delete by key with out getRf() method the not work with me. I don't know why
this does not do anything when clicking button delete
CodePudding user response:
There is no removing code line in your screenshot.
reference2.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
dataSnapshot.getRef.removeValue();
}
@Override
public void onCancelled(DatabaseError databaseError) {
//for database error
}
});
Or simply,
reference2.removeValue();
Don't post your code as image in the next time.
CodePudding user response:
Simply do this
reference2.child(YOUR_ITEM_KEY).setValue(null);