Reputation: 420
I have some data in the firebase database as shown in the below figure.
For Inserting I use, mFirebaseInstance.getReference("bus_tracking").child("service_no").child(busId).child("lon").setValue(obj.getLatitude());
I can't able to figure out how to retrive the same value, any suggestions will be appriciated. Thanks in advance.
I want to retrieve lat
value.
Upvotes: 0
Views: 39
Reputation: 80914
To retrieve lat
try the following :
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("bus_tracking").child("service_no");
databaseReference.child(busId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot mainSnapshot) {
String lat = mainSnapshot.child("lat").getValue(String.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d(TAG,databaseError.getMessage());
}
});
Add a reference to the node 1
then attach a listener and you will be able to retrieve the value of lat
Upvotes: 1