What are the trade-offs when I use sync on several paths in my Firebase database?
databaseRef.keepSynced(true);
I never clear the sync from th
When you use the keepSynced()
method, you're telling Firebase to download and cache all the data from databaseRef
. I hope databaseRef
isn't the root Reference of your Database because if it is, you're downloading your entire database and this is not a good practice.
You should use keepSynced()
to cache nodes that are really necessary for your app to work offline.
You will probably be wondering how is it different from setPersistanceEnabled(true)
. Well, setPersistanceEnabled(true)
only caches data when there is a Listener attached to that node (when the data has been read at least once).
On the other hand, keepSynced(true)
caches everything from that node, even if there is no listener attached.