Getting error 'java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file.' on pressing back and again opening the app in android Java SDK

Actually what I am doing is- On user Login defining the initial subscription like-

SyncConfiguration config = new SyncConfiguration.Builder(app.currentUser())
.initialSubscriptions(new SyncConfiguration.InitialFlexibleSyncSubscriptions(){
@Override
public void configure(Realm realm, MutableSubscriptionSet subscriptions) {
// add a subscription with a name

then in my splash screen activity I am setting up the default config in onCreate() like-

     Realm.init(this)
    if (app.currentUser()!=nulll)
            {

                    SyncConfiguration config = SyncConfiguration.defaultConfig(app.currentUser());
                   Realm.setDefaultConfiguration(config);
                 startActivity(new Intent(SplashScreenActivity.this,MainActivity.class));
           }
            else {
                startActivity(new Intent(SplashScreenActivity.this, RegisterUser.class));
            }

Then in my Main Activity,​ there are 3 fragments all of them using realm. And I am providing them real object by- Realm realm = Realm.getDefaultInstance(); I am writing this in OnCreateView() method

Everything is fine in the first go but if I press the back button to close app then again open app splash screen comes and the app crashes in MainActivity.
But instead of back if I am closing app by removing it from memory it is working fine.
So what I think is splash screen is setting different configurations but app is still in memory.
Any suggestions on what I can do to cope with this??

I also have the same problem. When i logout the user and then login the same user again, the error arises. Wheres if i logout a user and login with different user, the app works fine.
Any solutions ?