'How can i get the value inside the child and put it on a array
heres a image of my database:
heres my code
Query countQuery = databaseReference.child("evacuation").orderByChild("evacuationNumber");
List<Places> placesList = new ArrayList<>();
countQuery.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
Places places = snapshot.getValue(Places.class);
Sampleviewtxt.setText((CharSequence) places);
}
@Override
public void onChildChanged(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
}
@Override
public void onChildRemoved(@NonNull DataSnapshot snapshot) {
}
@Override
public void onChildMoved(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|