I am stuck at understanding the concept of making Firebase App Offline. As per the documentation, we need to call:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
But where should we call this? Is it should be used in every Activity of the Application? Because, when I am using this inside my Application class onCreate() method, my app crashes continuously.
So what is the best practice we should follow to make our app offline.
One more doubt is the difference between the above one and DatabaseReference.keppSynced(true);
Create an Application Class
public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); FirebaseDatabase.getInstance().setPersistenceEnabled(true); } }
And Change your manifest as
<application android:name=".MyApp" android:allowBackup="true" android:icon="@mipmap/ic_launcher"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With