I just realized that with a single line of code I can be able to use my app Online and Offline to access the Firebase Database ( learned here ).
I'm developing an app, as an MVP and Firebase study, and I'm using this two methods to grant access offline:
FirebaseDatabase database = FirebaseDatabase.getInstance();
database.setPersistenceEnabled(true);
DatabaseReference reference = getFirebaseDatabaseInstance().getReference();
reference.keepSynced(true);
So, my question is :
It's correct to use both of this methods ? Or should I use only setPersistenceEnabled(true)
?
I noticed that if I use keepSynced(true)
my app avoids loading every time I change into another Activity / Fragment.