faraz_ahmed_kamran faraz_ahmed_kamran - 1 year ago 77
Android Question

Firebase Database add node to JSON tree for android

I have the following structure in my Firebase Database JSON Tree:
enter image description here

Now I have the

node as the following in Android:

DatabaseReference requestsNode

How can I add another node
with all the information-childs (date, destination, origin, ...) to the
node? At the time of execution I do not know how many requests are already in the tree. So I do not know the increment

Answer Source

You can use push() method to add new child instead of deciding the index for your child. It is based on timestamp so it will always unique and sorted chronologically.

So for your case

ref = FirebaseDatabase.getInstance().getReference("requests");

Hope this helps, comment if you have questions :)