June 2018
Beginner to intermediate
394 pages
9h 2m
English
In a simple way, DataSnapshot can be accessed through the getValue method. We can use the child() method to reach to a specific path of a snapshot. Consider the following example code snippet that fetches the title:
String title = mDataSnapshot.child("message1").child("title").getValue(String.class);
And all the children can be accessed using the getChildren() method. Consider the following code that is reading all the child details inside a for each loop:
for (DataSnapshot child : mDataSnapshot.getChildren()) { Log.i(TAG, child.getKey()); Log.i(TAG, child.getValue(String.class));}
Read now
Unlock full access