I'm trying to get a reference to the fist item in a firebase "Array"
In my case it would be "ElmmycgjS1Nvq.../albums/-IrdMMds"

But I'm not sure how to contsturct the query:
dbRef.child("ElmmycgjS.../albums").???.child("name"); // = "Brothers in Arms"
Where ??? should be something like getFirst().
Suppose I don't know the Id of the first Album beforehand (-IrdMMds). I just need to get the first one. I've tried limitToFirst(1).getRef() but this didn't help.
You'll want a query that listens for the first child:
Query first = dbRef.child("ElmmycgjS.../albums").limitToFirst(1);
And then attach a listener to that query.
When you execute a query against the Firebase Database, there will potentially be multiple results. So the result of the query will be a list of those results. Even if there is only a single result, the it will be a list of one result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With