When you use the keepSynced()
method, you tell Firebase to load and cache all the data from databaseRef
. I hope that databaseRef
not the root directory of your database, because if so, you are loading your entire database, and that is not a good practice.
You must use keepSynced()
to cache the nodes that are really needed to run your application offline.
You might be wondering how it differs from setPersistanceEnabled(true)
. Well, setPersistanceEnabled(true)
caches data only when setPersistanceEnabled(true)
connected to this node when the data has been read at least once).
On the other hand, keepSynced(true)
caches everything from this node, even if a listener is not connected to it.
source share