Assuming that you want to get the values of details
and time
properties from all objects and also assuming that the details
property is of type String and the time
is ServerValue.TIMESTAMP, to solve this please use the following code:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference schedulesRef = rootRef.child("schedules");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String details = ds.child("details").getValue(String.class);
long time = ds.child("time").getValue(Long.class);
Log.d("TAG", details + " / " + time);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {}
};
schedulesRef.addListenerForSingleValueEvent(valueEventListener);