0

I am using Firebase Database. Even I tried , I have failed to build the correct json structure for my needs that I can get the needed data in just one call. So now I am thinking of using value listeners in a loop , but I don't know if it's ok doing that so I need your suggestions. Like this:

List<String> nodes; // These strings are different paths in my firebase json tree
FirebaseDatabase database=FirebaseDatabase.getInstance();

for (i=0; i<nodes.size() ; i++) {

  DatabaseReference reference = database.getReference().child(nodes.get(i));
  reference.addSingleValueEventListener(...);
  //do stuff with retrieved data 
}
  • What's the problem? – Frank van Puffelen Nov 27 '16 at 16:22
  • I wanted to ask if there is anything wrong with doing this. This is a network request in each loop , right? Could it produce problems? –  Nov 27 '16 at 18:27
  • It's a network call in every iteration, but they're all going over the same connection. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 – Frank van Puffelen Nov 27 '16 at 18:36

0 Answers0