How to read the data path ( key ) from firebase?

Hi,
I added a ’ Listeners ’ to firebase and i wanna figure out what is the path when data change in firebase ,
what i did is adding :
Path/State
to listener , the problem is : when reading the ’ key ’ it would be like that :
State
so how to identify the whole path ?
thanks in advance .

Hi,

so how to identify the whole path ?

There is no such possibility. To determine the path, you must create a listener on the end node and map the path to it.

I still can’t get it ,what if I have 2 Different paths having different names but having the same contents ?
Product1/State
Product2/State
And added the the two State as listeners
What exactly should I do when firebase data changed ?
Thanks a lot for your support .

When the listener is triggered, you need to write the path of this listener to the variable. There is another way - to create 1 listener, but when it works, you will need to loop through all children nodes and determine the one in which the data has changed.

Thanks a lot, I solved the problem by making an additional listener named it with the path name so when data changed it tells me who exactly changed to check .

Hi David,

I have the opposite problem. I have put the listener to listen to tag1/tag2, but when data changes, the ‘key’ variable gives me tag1 and not tag2. Could you please upload some pictures of your blocks after you corrected it?

Thank you in advance.

Hi again. I Actually solved it. Of course it was just a lack of attention of mine :sweat_smile:.

Cheers

Actually it’s the same problem !
I solved it by making an additional listener & child naming the wanted ’ Tag ’ then of it’s data changed i get that listener data changed .
So, how did you solve yours ?

In my case, in the listening block I had put tag1/(other variable). This other variable wasn’t a path in Firebase hehehehe

:rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: