as the title, even I use Keepsync(true) before query but firebase always get wrong value ( the previous value )

this is my code :


    ROOT_REF.child(CHILD_SETTINGS).child(Member.getUser_id())
                        .child(getMyUID()).keepSynced(true);

                ROOT_REF.child(CHILD_SETTINGS)
                            .child(Member.getUser_id()).child(getMyUID())
                            .addListenerForSingleValueEvent(new ValueEventListener() {
                                @Override
                                public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

                                    if (!dataSnapshot.hasChild(NO_MAKING_GROUP_SETTING))
                                        validList.add(Member);
                                    else unvalidList.add(Member);

                                    if (validList.size()+unvalidList.size()==mMemberToCheck.size()) {

                                        mValidCallBack.OnCallBack(validList);
                                        mUnValidCallBack.OnCallBack(unvalidList);

                                    }

                                }

                                @Override
                                public void onCancelled(@NonNull DatabaseError databaseError) {

                                }
                            });

this is the update value code:

ROOT_REF.child(CHILD_SETTINGS)
                    .child(getMyUID()).child(user_to_prevent)
                    .child(NO_MAKING_GROUP_SETTING)
                    .setValue(true);

// remove when I want to allow user to notify me 

   ROOT_REF.child(CHILD_SETTINGS)
                    .child(getMyUID()).child(user_to_allow)
                    .child(NO_MAKING_GROUP_SETTING)
                    .removeValue();

this is the database

enter image description here

Update : I think this post can help : Firebase Offline Capabilities and addListenerForSingleValueEvent

0 Answers