How can i make the app work offline with Firebase database

Tags: , , ,



My app gets the data while its connected to internet but I want the app to get the data offline from cache. Please help I’m new to Firebase.

Answer

Simply activate offline persistens as specified in the official documentation:

Firebase applications work even if your app temporarily loses its network connection. You can enable disk persistence with just one line of code:

FirebaseDatabase.getInstance().setPersistenceEnabled(true);


Source: stackoverflow