Reputation: 177
Firstly, I've gone through helpful posts like this one.
But the solutions aren't working for me. There is no error on the app or server side (logs reported no error). But even when I change data on server side, the app doesn't pick it up.
Background : It's a simple implementation. As I'm registering users, I'm storing their name data in realtime database (there is no hierarchy). The code snippet below is how I'm fetching data changes:
DatabaseReference ref1= FirebaseDatabase.getInstance().getReference();
ref1.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
usersList = new ArrayList<String>();
for(DataSnapshot dsp : dataSnapshot.getChildren())
{
usersList.add(String.valueOf(dsp.getValue()));
System.out.println(String.valueOf(dsp.getValue()));
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
System.out.println("database error");
}
});
Structure of my database (I've blanked out my app name and user ID): here's the image
Upvotes: 2
Views: 256
Reputation: 6939
The reason why it's not working :
There is no child node in your database. You directly Put the data inside the Database.
Usually There is parent node then all child (User's) nodes available in it. But after seeing your database structure i don't find the Child Node which contains all user nodes list.
If you provide the data insertion code might help us provide answer and improve your database structure.
Upvotes: 1