I have been using and testing my Android app thoroughly for the last 2 weeks.
I am using the Firebase Realtime Database exhaustively in my app and the most important thing is that, my app needs to work offline seamlessly.
I have a splash screen, where I sync all the data for a particular user node just while starting and proceed.
I using keepSynced(true);
and setPersistenceEnabled(true);
for sure.
Have noticed a serious issue, which is causing a lot of problem.
Scenario 1
I run the app for the first time with internet connection, the app works fine.
Scenario 2
I run the app for the first time without internet connection, nothing works. No callback is fired.
Scenario 3
I run the app consecutively with/without internet connection, it works fine.
Scenario 4
But, when I run the app after 1 or 2 days without internet connection, nothing works. No callback is fired.
I seems that the disk persistence is cleared automatically, that is why the data is not available offline and no callback is fired.
So, how can I control when the disk persistence is cleared? Is there a way to make sure that the persistence is never cleared? Is there a way to configure the size of the disk persistence also?
EDIT
This is what I am doing in the onCreate()
of my application class.
private void initializeFirebaseDatabase() {
if (!FirebaseApp.getApps(this).isEmpty()) {
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
firebaseDatabase.setPersistenceEnabled(true);
}
}