why can not I make a ValueEventListener within a For cycle?

0

I want to make several calls with a For a Firebase cycle using the ValueEventListener or also with the ListenerForSingleEvent but the for is thrown to the last value of the "i" counter and there is only one call and not of each value, A that?

 for(i=0;i<CODIGOstring.size();i++) {
   Query q1 = FirebaseDatabase.getInstance().getReference("Usuario").orderByChild("Codigo").equalTo(CODIGOstring.get(i));
        q1.addListenerForSingleValueEvent(new ValueEventListener() {......etc

Or this:

for(i=0;i<CODIGOstring.size();i++) {
   mRootReference.child("Usuario").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {...etc
    
asked by Pedro N. 19.11.2018 в 02:31
source

0 answers