title: Shared preferences not working as expected
body: <p>Below is my code to the MainActivity.java of my project, this is the welcome like screen for my app and should only appear first time user opens the app. Otherwise the user should get to see the Medicine_Activity.java which is also triggered when the user presses "Get Started" button on MainActivity. In order to implement this i came across something known as SharedPreferences and tried to implement it. But it isnt working quite as expected, the MainActivity flashes for a second before Medicine_Activity is launched. I am new so please help me out</p>
  
  <p>Here is a video clip to view this bug in action - <a href="https://www.dropbox.com/s/fqbo9urb6xnh3pd/WhatsApp%20Video%202019-06-20%20at%202.12.50%20PM.mp4?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/fqbo9urb6xnh3pd/WhatsApp%20Video%202019-06-20%20at%202.12.50%20PM.mp4?dl=0</a></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements View.OnClickListener {
      Button btnGetStarted;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
          boolean previouslyStarted = prefs.getBoolean(getString(R.string.pref_previously_started), false);
          if(!previouslyStarted) {
              SharedPreferences.Editor edit = prefs.edit();
              edit.putBoolean(getString(R.string.pref_previously_started), Boolean.TRUE);
              edit.apply();
          } else{
              Intent intent = new Intent(this, Medicine_Activity.class);
              startActivity(intent);
          }
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title
          getSupportActionBar().hide(); // hide the title bar
          this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen
          setContentView(R.layout.activity_main);
  
          Button btnGetStarted = findViewById(R.id.btnGetStarted);
          btnGetStarted.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View v) {
          Intent intent = new Intent(this, Medicine_Activity.class);
          startActivity(intent);
      }
  }
  </code></pre>