@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mUserPreference = new UserPreference(MainActivity.this); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); View headerView = navigationView.getHeaderView(0); TextView txtUsername = (TextView) headerView.findViewById(R.id.txt_username); TextView txtEmail = (TextView) headerView.findViewById(R.id.txt_email); txtUsername.setText(mUserPreference.getName()); txtEmail.setText(mUserPreference.getEmail()); if (mCurrentLocationFragment == null) { mCurrentLocationFragment = new CurrentLocationFragment(); } setUpFragment(mCurrentLocationFragment, CurrentLocationFragment.class.getSimpleName()); }