Hammad Nasir Hammad Nasir - 1 year ago 112
Android Question

Value not getting removed from firebase

I'm trying to remove some value stored at a particular reference on firebase.

Here's how I have stored it:


Here's how I'm trying to remove it:


has been generated in
using this code:

itemIDFU = mDatabase.child("users").child(uid).push().getKey();

The problem is that it is getting stored successfully, but not getting removed.

What's going wrong here?

Please let me know.

Answer Source

It looks like when you set the value, you set the key itemIDFU to equal whatever value is in MainActivity.uid

However, when you delete the data, you are trying to get the child of itemIDFU, which doesn't exist.

You didn't add MainActivity.uid as the child of itemIDFU, you added it as the value.

You have two possible solutions:

Try this if you want to remove the value, but leave the itemIDFU key there empty:


Try this if you want to completely remove the key and value:


Here is a picture to help illustrate the data and the problem:

enter image description here

One more picture to explain

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download