Skip to content
Advertisement

Get specific child data from firebase

I have to access a child from a node. I have only “value” for a specific child and to get the Type value from the same node.

I have to return the value:

Structure

I’ve done a lot of googling and I just can’t figure out how this works. My current version of the java code is this.

JavaScript

Advertisement

Answer

Get a specific node inside Category

If you want to get the node which id is 1, you could try this:

JavaScript

Output of the code above:

JavaScript

Get all nodes inside Category

If you want to read all the node inside Category, just provide an array of hash map or class and change the onDataChange method like this:

JavaScript

but first, you have to create the ExampleClass file with setter and getter functions inside it.

Output:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement