0

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.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • you can parse the data as HashMap and use the data instead of for loop – KKSINGLA Apr 27 '20 at 05:39
  • Does this answer your question? [Retrieving data from Firebase Realtime Database in Android](https://stackoverflow.com/questions/39714936/retrieving-data-from-firebase-realtime-database-in-android) – Ravi Apr 27 '20 at 06:00

0 Answers0