Not cache a specific part of a Firebase database in Android at all

Viewed 403

In my use-case, I do not want to cache a specific part of the Firebase Database at all in my Android app.

I have tried the following things:

1) This change is made in the Application class of my app.

FirebaseDatabase.getInstance().setPersistenceEnabled(false);
FirebaseDatabase.getInstance().getReference().child("point-To-Place-I-don't-wanna-cache").keepSynced(false);

2) Removed FirebaseDatabase.getInstance().setPersistenceEnabled();from the application class.
Put FirebaseDatabase.getInstance().getReference().child("point-To-Place-I-don't-wanna-cache").keepSynced(false);in the activity before database access.

3) A few more combinations of the above commands.

Nothing seemed to work.

1 Answers

When you call setPersistenceEnabled(true), all data that the client recently received is cached to disk.

There is no way to exclude certain nodes from that disk persistence.

Related