AbAppletic AbAppletic - 3 months ago 29
Android Question

Firebase - Is there a method for returning to root in Firebase?

Let's say I have this database:

Database:{
-Blah1{
name: "Hello SO"
}
}


And currently, I am at "name" (by
database.child("-Blah1").child("name")
)

So, how can I return to the root of the tree? (In this case, "Database")

Answer

You can get a root reference by calling the root function from any child reference:

var rootReference = database.child("-Blah1").child("name").getRoot();

https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference.html#getRoot()

Comments