Mastering Firebase for Android Development
上QQ阅读APP看书,第一时间看更新

Offline capabilities

At the point when clients are disconnected from the internet, the Realtime Database SDKs employ local cache on the device to store changes. Later when the device comes online, the local data is automatically synchronized to Realtime Database. We can enable disk persistence to save the data offline from the following lines of code:

//Offline support
FirebaseDatabase.getInstance().setPersistenceEnabled(true);