Firebase Database firebaseDatabase = FirebaseDatabase.getInstance();
DatabaseReference myReference = firebaseDatabase.getReference("room");
myReference.child("titleSet").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
for (DataSnapshot dataSnapshot1: dataSnapshot.getChildren()){
TitleSet title = dataSnapshot1.getValue(TitleSet.class); //your Object
String myTitle = title.getTitle();
Toast.makeText(getActivity(), "Titles: "+myTitle, Toast.LENGTH_SHORT).show();
}
//set your adapter here
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
你也可以看看这个
link
了解有关在Firebase中检索数据的更多信息。