title: Retrieve Firebase Data and Display in ListView in Android Studio
body: <p>I am currently building an Android app and using Firebase as its backend database, however i'm having difficulties to retrieve the data and display them in a <code>ListView</code>. I tried few codes but the app is crashing as soon as i display the list activity.</p>
  
  <p>Below is a screenshot of my database and also my code and the error I get when I try to run:</p>
  
  <p>Firebase Database</p>
  
  <p><a href="https://i.stack.imgur.com/s6Tgs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s6Tgs.png" alt="enter image description here"></a></p>
  
  <pre><code>public class ClientLIstActivity extends AppCompatActivity {
  
  private Button clientSelect;
  private ListView clientlistView;
  private FirebaseDatabase database;
  private DatabaseReference databaseReference;
  
  private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  private ArrayAdapter&lt;String&gt; adapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_client_list);
  
      clientlistView = (ListView) findViewById(R.id.clientListView);
      adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,list);
      clientlistView.setAdapter(adapter);
      adapter.notifyDataSetChanged();
      databaseReference = FirebaseDatabase.getInstance().getReference().child("Clients");
  
  
      clientSelect = (Button) findViewById(R.id.selectClient);
  
      clientSelect.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              onBackPressed();
          }
      });
  
      databaseReference.addChildEventListener(new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s) {
             String value = dataSnapshot.getValue(String.class);
             list.add(value);
          }
  
          @Override
          public void onChildChanged(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onChildRemoved(DataSnapshot dataSnapshot) {
  
          }
  
          @Override
          public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  }
  
  
  }
  </code></pre>
  
  <p>Error Log:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.javytharanee.quicksolattendance, PID: 6602
                com.google.firebase.database.DatabaseException: Failed to convert value of type java.util.HashMap to String
                    at com.google.android.gms.internal.zzepg.zzb(Unknown Source:93)
                    at com.google.android.gms.internal.zzepg.zza(Unknown Source:0)
                    at com.google.firebase.database.DataSnapshot.getValue(Unknown Source:10)
                    at com.javytharanee.quicksolattendance.ClientLIstActivity$2.onChildAdded(ClientLIstActivity.java:53)
                    at com.google.android.gms.internal.zzegg.zza(Unknown Source:71)
                    at com.google.android.gms.internal.zzelk.zzcal(Unknown Source:2)
                    at com.google.android.gms.internal.zzelq.run(Unknown Source:71)
                    at android.os.Handler.handleCallback(Handler.java:873)
                    at android.os.Handler.dispatchMessage(Handler.java:99)
                    at android.os.Looper.loop(Looper.java:193)
                    at android.app.ActivityThread.main(ActivityThread.java:6669)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  </code></pre>
  
  <p>Client Object Class: </p>
  
  <pre><code>public class Client {
  String name;
  String location;
  String latitude;
  String longitude;
  
  public Client(String location, String latitude, String longitude) {
      this.location = location;
      this.latitude = latitude;
      this.longitude = longitude;
  }
  
  public Map toMap() {
      Map client = new HashMap();
  
      client.put("Name", this.name);
      client.put("Location", this.location);
      client.put("Latitude", this.latitude);
      client.put("Longitude", this.longitude);
  
      return client;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  }
  </code></pre>