Skip to content Skip to sidebar Skip to footer

Firebase Database Not Syncing Properly

I'm trying to make a chat application. For that I'm using firebase database. And to show messages using FirebaseRecyclerAdapter. mNewAdapter = new NewChatRecyclerAdapter(

Solution 1:

The Firebase Database only synchronizes data while there is an active connection to the server. This normally only happens when the app is active, since Android closes the connection when the app is inactive.

While there is a connection, the Firebase SDK normally only synchronizes data in a location when you have an active listener in that location. When you call keepSynced(true) on a location, it will also synchronize when there is no active listener in the location.

Calling keepSynced(true) is most useful for the main list in your app, such as the data you show in your main activity. By keeping that synchronized, it will also be updated when your users are in a different screen. That way, when they come back to the main activity, the data is immediately available.

To reduce the time the user has to wait when restarting the app, you can tell Firebase to store its cache to disk by calling setPersistenceEnabled(true). Since loading from disk is typically faster than loading from network, this may speed things up.

Solution 2:

Enabling Offline Capabilities so as your app will cache those data

FirebaseDatabase.getInstance().setPersistenceEnabled(true);

Enabling Offline Capabilities

Post a Comment for "Firebase Database Not Syncing Properly"