I want to show a list of countries in my app, which should be retrieved from Firebase Database. The list is now put in like this: printsceen of Firebase Database list of countries
With an addValueEventListener I want to search for the right path, to retrieve the value of the names of the country.
private void getCountryList(DataSnapshot dataSnapshot) {
myRef = FirebaseDatabase.getInstance().getReference()
.child("countries");
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot countrySnapshot : dataSnapshot.getChildren()) {
String country = countrySnapshot.getValue().toString();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
I hope that someone can help me oout with this.