Reputation: 73
My firebase looks like this
I have this code to retrieve my data and it does print out all my data in my logcat here , but I only want to grab (Annotation_City:) and print it to the device. I've tried other stack questions and answers but still haven't figured it out :) thank you if you can help! :)
public void AllLocationMarkers() {
grabMarkersFromDb = new Firebase("***");
grabMarkersFromDb.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot locationSnapshot : dataSnapshot.getChildren()) {
String location = locationSnapshot.getValue().toString();
Log.d("Locations updated", "location: " + location + "-----------------------------------------------------------------------------------------------------");
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
Upvotes: 1
Views: 473
Reputation: 139039
To solve this, change this line:
String location = locationSnapshot.getValue().toString();
with this:
String location = (String) locationSnapshot.child("Annotation_City").getValue();
Hope it helps.
Upvotes: 1