title: Retrieving data from Firebase in Android
body: <p>My Database looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/gab3H.png" alt="Firebase Databse"></p>
  
  <p>The code of my activity is this:</p>
  
  <pre><code>    public class FirebaseActivity extends AppCompatActivity {
  
      ListView lv;
  
      private FirebaseDatabase database;
      private DatabaseReference myRef;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_firebase);
  
          final List&lt;String&gt; glocations = new ArrayList&lt;String&gt;();
  
          lv = (ListView) findViewById(R.id.lv);
  
          database = FirebaseDatabase.getInstance();
          myRef = database.getReference();
          myRef.child("Users").addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                 Iterable&lt;DataSnapshot&gt; children = dataSnapshot.getChildren();
  
                  for (DataSnapshot child: children){
                      String data = child.getValue(String.class);
                      glocations.add(data);
  
                  }
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,glocations);
  
          lv.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>Now whenever I try to open the activity from the settings menu on the main activity my application crashes. All I want it to do is show the Latitude, the longitude and the timestamps each time the user changes them in a listview by using a simple list with the array adapter.
  This is a different activity and not the main one. The main one works perfectly. I've watched countless videos and I cannot understand my mistake.</p>
  
  <p>The Error I get from logcat is this</p>
  
  <blockquote>
    <p>FATAL EXCEPTION: main
                                                                                  Process: com.thanoszoug.geofenceexample, PID: 9954
                                                                                  com.google.firebase.database.DatabaseException: Failed to convert
    value of type java.util.HashMap to String
                                                                                      at com.google.android.gms.internal.zzbqi.zzaD(Unknown Source)
                                                                                      at com.google.android.gms.internal.zzbqi.zzb(Unknown Source)
                                                                                      at com.google.android.gms.internal.zzbqi.zza(Unknown Source)
                                                                                      at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
                                                                                      at
    com.thanoszoug.geofenceexample.FirebaseActivity$1.onDataChange(FirebaseActivity.java:42)
                                                                                      at com.google.android.gms.internal.zzbmz.zza(Unknown Source)
                                                                                      at com.google.android.gms.internal.zzbnz.zzYj(Unknown Source)
                                                                                      at com.google.android.gms.internal.zzboc$1.run(Unknown Source)
                                                                                      at android.os.Handler.handleCallback(Handler.java:739)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                      at android.os.Looper.loop(Looper.java:158)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)</p>
  </blockquote>