Home > database >  Is there anyway to save firebase realtime db data when internet connection is not available
Is there anyway to save firebase realtime db data when internet connection is not available

Time:11-01

I am making an attendance android app in kotlin. In this app, students list is available offline with sqlite db.

For attendance saving i am using Firebase Realtime Database.

But, i want to make app which can work in offline mode also. And upload attendance when internet available, Even after restarting the application.

CodePudding user response:

IMHO, I cannot see any benefit of implementing this mechanism since the Realtime Database has its own offline persistence mechanism. According to the official documentation:

Firebase apps automatically handle temporary network interruptions. Cached data is available while offline and Firebase resends any writes when network connectivity is restored.

When you enable disk persistence, your app writes the data locally to the device so your app can maintain its state while offline, even if the user or operating system restarts the app.

So while offline, you can continue using the app. In Android, this can be simply done using:

Firebase.database.setPersistenceEnabled(true)
  • Related