5

I was playing with Firebase, removing and adding users.
Then I decided to delete all my users and now I still can access nodes that doesn't exist anymore.
Below is how I'm retrieving the dataSnapshot and a print from my most recent Firebase database.

mFirebaseUsersRef = new Firebase(Constants.FIREBASE_URL_USERS).child(mLoggedUser.getEmail());

    mFirebaseUsersRef.addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if(dataSnapshot.exists()) {
                mLoggedUser = dataSnapshot.child(mLoggedUser.getEmail()).getValue(User.class);

Firebase database image
Notice that there's only one user on the users list, however if my mFirebaseUsersRef referencies an email that had a node before deleting all my users at my Firebase database, but now doesn't exist, the dataSnapshot will retrieve all the data that existed before deleting the node.
I hope I made myself clear, I will be pleased to answer any doubt about my question.

Below is a print of the nonexistent data that my dataSnapshot is retrieving
Ghost data

EDIT
After debugging each line, I noticed something odd, the dataSnapshot at first exist as shown here: Ghost data, but after going through the entire if (even through startActivity(i);) it returns to if(dataSnapshot.exists()) { and shows that the dataSnapshot is now null: Now node is null

Douglas Pfeifer
  • 147
  • 1
  • 8
  • The only way I can think of is that you have disk persistence enabled and the data is being served from there. Any chance that's it? – Frank van Puffelen Jul 12 '16 at 04:23
  • Is disk persistence on by default? If so, then this could be the problem, however I didn't implemented this: `Firebase.getDefaultConfig().setPersistenceEnabled(true);` – Douglas Pfeifer Jul 12 '16 at 04:32
  • I think it's off by default. And it would also only cause this behavior if you don't have a network connection. But as said: it's the only explanation that quickly comes to mind. – Frank van Puffelen Jul 12 '16 at 04:35
  • The fact that the app reads the if twice, first recognizing the node as existent and then as null should mean something? – Douglas Pfeifer Jul 12 '16 at 04:56
  • That sounds like the initial event is firing from the local cache and then once the server updates come in it fires a reconciliation event. – Frank van Puffelen Jul 12 '16 at 19:37
  • I see, is there a way to prevent the app from receiving the data from the local cache? – Douglas Pfeifer Jul 14 '16 at 19:11
  • Seems you are working off your local cache, can you confirm you have internet access? Disabling local cache should do the rick : Firebase.getDefaultConfig().setPersistenceEnabled(false); – jirungaray Jul 26 '16 at 14:48

0 Answers0