title: Android Firebase - setPersistenceEnabled(true) crashing the app
body: <p>So I was just trying out Firebase to update Toolbar label of activities from realtime database. I am getting the following error:</p>
  
  <pre><code>12-21 00:25:19.890 10295-10295/com.xlr8labs.FirebaseAuth E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: com.xlr8labs.FirebaseAuth, PID: 10295
                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xlr8labs.FirebaseAuth/com.xlr8labs.FirebaseAuth.RegisterActivity}: com.google.firebase.database.DatabaseException: Calls to setPersistenceEnabled() must be made before any other usage of FirebaseDatabase instance.
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2341)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393)
                                                                             at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                             at android.os.Looper.loop(Looper.java:193)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5295)
                                                                             at java.lang.reflect.Method.invokeNative(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:515)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                                                                             at dalvik.system.NativeStart.main(Native Method)
                                                                          Caused by: com.google.firebase.database.DatabaseException: Calls to setPersistenceEnabled() must be made before any other usage of FirebaseDatabase instance.
                                                                             at com.google.firebase.database.FirebaseDatabase.zzhM(Unknown Source)
                                                                             at com.google.firebase.database.FirebaseDatabase.setPersistenceEnabled(Unknown Source)
                                                                             at com.xlr8labs.FirebaseAuth.RegisterActivity.onCreate(RegisterActivity.java:35)
                                                                             at android.app.Activity.performCreate(Activity.java:5264)
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393) 
                                                                             at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324) 
                                                                             at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                             at android.os.Looper.loop(Looper.java:193) 
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5295) 
                                                                             at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                             at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) 
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
                                                                             at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>
  
  <p>Even though I'm using setPersistenceEnabled() before calling any other methods on my database instance, I'm still getting this error. Here is my Activity.java code:</p>
  
  <pre><code>public class RegisterActivity extends AppCompatActivity {
   private FirebaseDatabase mFirebaseInstance;
   @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_register);
          // ------------------ Update activity label from database in realtime ------
          mFirebaseInstance = FirebaseDatabase.getInstance();
          mFirebaseInstance.setPersistenceEnabled(true);
          mFirebaseInstance.getReference("RegisterLabel").keepSynced(true);
          mFirebaseInstance.getReference("RegisterLabel").addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  Log.e(LOG_TAG,"Register label changed");
                  String appTitle = dataSnapshot.getValue().toString();
                  getSupportActionBar().setTitle(appTitle);
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
          // ---------------------------------------------------------------------------
  </code></pre>
  
  <p>What is causing the crash. I'm using the exact same snippet on two other activities...</p>