this is the class where i have done my login code and after login it fetches name and email of user to shoe. The fetching process is working well but when i try to set text of different layout xml file it gives me null pointer exception.
this is the NavigationMenu class here is my login function
   FragmentTransaction fragmentTransaction;
    NavigationView navigationView;
    RoundImage roundedImage;
    ImageView profileImage;
    TextView uname,mail;
    private SQLiteHandler db;
    private SessionManager session;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_navigation_menu);
        toolbar = (Toolbar)findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        db = new SQLiteHandler(getApplicationContext());
        HashMap<String,String> user = db.getUserDetails();
        String name = user.get("name");
        String email = user.get("email");
        Log.d("Soulsystem", name);
        Log.d("Soulsystem", email);
        uname = (TextView)findViewById(R.id.alluser);
        mail = (TextView) findViewById(R.id.allemail);
        try {
            uname.setText(name);
            mail.setText(email);
        }catch (NullPointerException NPE)
        {
            Log.d("Soul system","Here is the error we are setting null values");
        }
       /* profileImage = (ImageView)view.findViewById(R.id.navigation_view_Image);
        profileImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("NavigationMenu", "In profile Image view");
                Intent i = new Intent(NavigationMenu.this, ClientProfile.class);
            }
        });*/
        drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,R.string.drawer_open,R.string.drawer_close);
        drawerLayout.setDrawerListener(actionBarDrawerToggle);
        fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.main_container,new HomeFragment());
        fragmentTransaction.commit();
        // session manager
        session = new SessionManager(getApplicationContext());
        if (!session.isLoggedIn()) {
            logoutUser();
        }
        navigationView = (NavigationView)findViewById(R.id.navigation_view);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem item) {
                switch (item.getItemId()){
                    case R.id.profile:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new ClientProfile());
                        fragmentTransaction.commit();
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.logout:
                        logoutUser();
                       /* item.setChecked(true);
                        drawerLayout.closeDrawers();*/
                        break;
                }
                return true;
            }
        });
    }
    protected void onPostCreate(@Nullable Bundle savedInstanceState) {
        actionBarDrawerToggle.syncState();
        super.onPostCreate(savedInstanceState);
    }
    private void logoutUser() {
        session.setLogin(false);
        db.deleteUsers();
        Intent intent = new Intent(NavigationMenu.this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}And this one the Navigation menu xml file here I tried to set text and its working file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"
    tools:context="com.example.user.soulsystem.MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <include
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            layout="@layout/toolbar_layout"/>
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/main_container">
            <TextView
                android:id="@+id/alluser"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView
                android:gravity="center_horizontal"
                android:id="@+id/allemail"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </FrameLayout>
    </LinearLayout>
    <android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/navigation_view"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_drawer_header"
        app:menu="@menu/drawe_menu">
    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>This one the xml where i want to show the text how can i do this i tried using Layout Interline but when i tried to set text it is giving me null pointer exception on setText()
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/bg_register">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp" >
    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:id="@+id/navigation_view_Image"
        android:background="@drawable/image"
        android:src="@drawable/profile_image"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="10dp"/>
    <TextView
        android:layout_below="@id/navigation_view_Image"
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:id="@+id/username"
        android:textColor="@color/Black"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="10dp"
        android:layout_alignLeft="@+id/navigation_view_Image"
        android:layout_alignStart="@+id/navigation_view_Image" />
        </LinearLayout>
    <TextView
        android:layout_below="@id/username"
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:id="@+id/email"
        android:textColor="@color/Black"
        android:layout_alignLeft="@+id/navigation_view_Image"
        android:layout_alignStart="@+id/navigation_view_Image" />
</LinearLayout> 
     
    