How to save a part of firebase realtime database in offline mode

前端 未结 2 1658
梦谈多话
梦谈多话 2021-01-27 09:01

I wanted to store the specific path in Firebase database (JSON) in local phone storage, not all data at the realtime-Firebase database. Say I have a news-feed path for each user

2条回答
  •  死守一世寂寞
    2021-01-27 10:04

    Those two bits of code are not really related. They don't do the same thing.

    keepSynced(true) effectively keeps a listener active on the given reference, from the moment it's called, for as long as the app is running, so that the local version of the data is always in sync with the remote version on the server.

    setPersistenceEnabled(true) just activates local caching of the data read by the SDK. When persistence is enabled, the app can still query data previously read. It takes effect for all data read by the SDK. While persistence is enabled, you can't control which data is cached - all read data is cached up to 10MB max. When the max is reached the oldest data will be evicted from the cache.

提交回复
热议问题