title: add profile page using fragment and firebase in android studio default navigation drawer
body: <p>I am new to android studio. I am currently developing a app with android studio navigation drawer template. But I am unable to add a profile page. Please help. have been stuck for almost 6 days.
  I am also using firebase in my project. I have created a class user.java. which i have attached.
  i want to get data from my firebase and then display in profile page and also be able to edit it.
  <a href="https://i.stack.imgur.com/BJeac.png" rel="nofollow noreferrer">Screenshot of user information from realtime database</a></p>
  <p><strong>ProfileFragment.java</strong></p>
  <pre><code>package com.su.navygayion7;
  
  import android.os.Bundle;
  
  import androidx.fragment.app.Fragment;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  /**
   * A simple {@link Fragment} subclass.
   * Use the {@link ProfileFragment#newInstance} factory method to
   * create an instance of this fragment.
   */
  public class ProfileFragment extends Fragment {
  
      // TODO: Rename parameter arguments, choose names that match
      // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
      private static final String ARG_PARAM1 = &quot;param1&quot;;
      private static final String ARG_PARAM2 = &quot;param2&quot;;
  
      // TODO: Rename and change types of parameters
      private String mParam1;
      private String mParam2;
  
      public ProfileFragment() {
          // Required empty public constructor
      }
  
      /**
       * Use this factory method to create a new instance of
       * this fragment using the provided parameters.
       *
       * @param param1 Parameter 1.
       * @param param2 Parameter 2.
       * @return A new instance of fragment ProfileFragment.
       */
      // TODO: Rename and change types and number of parameters
      public static ProfileFragment newInstance(String param1, String param2) {
          ProfileFragment fragment = new ProfileFragment();
          Bundle args = new Bundle();
          args.putString(ARG_PARAM1, param1);
          args.putString(ARG_PARAM2, param2);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              mParam1 = getArguments().getString(ARG_PARAM1);
              mParam2 = getArguments().getString(ARG_PARAM2);
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_profile, container, false);
      }
  }
  </code></pre>
  <p><strong>fragment_profile.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.ProfileFragment&quot;
      android:background=&quot;@color/white&quot;&gt;
  
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;com.google.android.material.appbar.AppBarLayout
              android:id=&quot;@+id/appbar&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;192dp&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
              &lt;com.google.android.material.appbar.CollapsingToolbarLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  app:contentScrim=&quot;?attr/colorPrimary&quot;
                  app:layout_scrollFlags=&quot;scroll|exitUntilCollapsed&quot;
                  app:toolbarId=&quot;@+id/toolbar&quot;&gt;
  
                  &lt;ImageView
                      android:id=&quot;@+id/image_profile&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;182dp&quot;
                      android:gravity=&quot;center_vertical&quot;
                      android:src=&quot;@drawable/ic_profileb&quot;
                      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
                  &lt;androidx.appcompat.widget.Toolbar
                      android:id=&quot;@+id/toolbar&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;?attr/actionBarSize&quot;&gt;&lt;/androidx.appcompat.widget.Toolbar&gt;
              &lt;/com.google.android.material.appbar.CollapsingToolbarLayout&gt;
          &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
          &lt;androidx.core.widget.NestedScrollView
              android:id=&quot;@+id/nestedScrollView2&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layout_marginTop=&quot;210dp&quot;
              app:layout_behavior=&quot;android.support.design.widget.AppBarLayout$ScrollingViewBehavior&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
              &lt;LinearLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:orientation=&quot;vertical&quot;&gt;
  
                  &lt;TextView
                      android:id=&quot;@+id/textViewProfile&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:gravity=&quot;center_horizontal&quot;
                      android:text=&quot;Profile&quot;
                      android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;
                      android:textColor=&quot;@color/black&quot;
                      android:textSize=&quot;35sp&quot; /&gt;
  
                  &lt;TableRow
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:weightSum=&quot;2&quot;&gt;
  
                      &lt;ImageView
                          android:id=&quot;@+id/imageViewName&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;match_parent&quot;
                          android:layout_marginLeft=&quot;5dp&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginRight=&quot;5dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          app:srcCompat=&quot;@drawable/ic_baseline_account_circle_24&quot; /&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/fullname&quot;
                          android:layout_width=&quot;280dp&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          android:text=&quot;Name&quot;
                          android:textColor=&quot;@color/black&quot;
                          android:textSize=&quot;25sp&quot; /&gt;
  
  
                  &lt;/TableRow&gt;
  
  
  
                  &lt;TableRow
                      android:layout_width=&quot;fill_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:weightSum=&quot;2&quot;&gt;
  
                      &lt;ImageView
                          android:id=&quot;@+id/imageViewPhone&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;match_parent&quot;
                          android:layout_marginLeft=&quot;5dp&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginRight=&quot;5dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          app:srcCompat=&quot;@drawable/ic_baseline_phone&quot; /&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/text_phone&quot;
                          android:layout_width=&quot;280dp&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          android:text=&quot;dies&quot;
                          android:textColor=&quot;@color/black&quot;
                          android:textSize=&quot;25sp&quot; /&gt;
  
  
                  &lt;/TableRow&gt;
  
                  &lt;TableRow
                      android:layout_width=&quot;fill_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:weightSum=&quot;2&quot;&gt;
  
                      &lt;ImageView
                          android:id=&quot;@+id/imageViewMail&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;match_parent&quot;
                          android:layout_marginLeft=&quot;5dp&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginRight=&quot;5dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          app:srcCompat=&quot;@drawable/ic_baseline_email&quot; /&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/text_email&quot;
                          android:layout_width=&quot;377dp&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          android:text=&quot;mail_address&quot;
                          android:textColor=&quot;@color/black&quot;
                          android:textSize=&quot;25sp&quot; /&gt;
                  &lt;/TableRow&gt;
                  &lt;TableRow
                      android:layout_width=&quot;fill_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:weightSum=&quot;2&quot;&gt;
  
                      &lt;ImageView
                          android:id=&quot;@+id/imageViewBio&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;match_parent&quot;
                          android:layout_marginLeft=&quot;5dp&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginRight=&quot;5dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          app:srcCompat=&quot;@drawable/ic_info&quot; /&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/text_bio&quot;
                          android:layout_width=&quot;377dp&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_marginTop=&quot;1dp&quot;
                          android:layout_marginBottom=&quot;1dp&quot;
                          android:text=&quot;Bio&quot;
                          android:textColor=&quot;@color/black&quot;
                          android:textSize=&quot;25sp&quot; /&gt;
                  &lt;/TableRow&gt;
  
                  &lt;Button
                      android:id=&quot;@+id/edit_profile&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_gravity=&quot;center_horizontal&quot;
                      android:layout_marginTop=&quot;20dp&quot;
                      android:layout_marginBottom=&quot;20dp&quot;
                      android:gravity=&quot;center&quot;
                      android:onClick=&quot;navigateLogOut&quot;
                      android:text=&quot;Edit Profile&quot;
                      android:textColor=&quot;@color/black&quot;
                      android:textSize=&quot;20sp&quot; /&gt;
              &lt;/LinearLayout&gt;
          &lt;/androidx.core.widget.NestedScrollView&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>
  <p><strong>MainActivity.java</strong></p>
  <pre><code>package com.su.navygayion7;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.Menu;
  import android.view.accessibility.AccessibilityNodeInfo;
  
  import com.google.android.material.snackbar.Snackbar;
  import com.google.android.material.navigation.NavigationView;
  
  import androidx.navigation.NavController;
  import androidx.navigation.Navigation;
  import androidx.navigation.ui.AppBarConfiguration;
  import androidx.navigation.ui.NavigationUI;
  import androidx.drawerlayout.widget.DrawerLayout;
  import androidx.appcompat.app.AppCompatActivity;
  
  import com.google.firebase.auth.FirebaseAuth;
  import com.su.navygayion7.databinding.ActivityMainBinding;
  
  public class MainActivity extends AppCompatActivity {
  
      private AppBarConfiguration mAppBarConfiguration;
      private ActivityMainBinding binding;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          binding = ActivityMainBinding.inflate(getLayoutInflater());
          setContentView(binding.getRoot());
  
          setSupportActionBar(binding.appBarMain.toolbar);
          binding.appBarMain.fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Snackbar.make(view, &quot;Replace with your own action&quot;, Snackbar.LENGTH_LONG)
                          .setAction(&quot;Action&quot;, null).show();
              }
          });
          DrawerLayout drawer = binding.drawerLayout;
          NavigationView navigationView = binding.navView;
          // Passing each menu ID as a set of Ids because each
          // menu should be considered as top level destinations.
          mAppBarConfiguration = new AppBarConfiguration.Builder(
                  R.id.nav_Profile, R.id.nav_home, R.id.nav_dashboard, R.id.nav_test, R.id.nav_info, R.id.nav_contact)
                  .setOpenableLayout(drawer)
                  .build();
          NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
          NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
          NavigationUI.setupWithNavController(navigationView, navController);
          NavigationView navigationView1 = findViewById(R.id.nav_view);
          navigationView1.getMenu().findItem(R.id.nav_logout).setOnMenuItemClickListener(menuItem -&gt; {
              FirebaseAuth.getInstance().signOut();
              startActivity(new Intent(MainActivity.this , StartActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
              finish();
              return true;
          });
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public boolean onSupportNavigateUp() {
          NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
          return NavigationUI.navigateUp(navController, mAppBarConfiguration)
                  || super.onSupportNavigateUp();
      }
  }
  </code></pre>
  <p><strong>User.java</strong></p>
  <pre><code>package com.su.navygayion7.Model;
  
  public class User {
  
      private String id;
      private String email;
      private String fullname;
      private String phone;
      private String imageurl;
      private String bio;
  
      public User(String name, String surname, String phoneno) {
      }
  
      public User(String id, String email, String fullname, String imageurl, String bio, String phone) {
          this.id = id;
          this.email = email;
          this.fullname = fullname;
          this.imageurl = imageurl;
          this.bio = bio;
          this.phone = phone;
      }
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getFullname() {
          return fullname;
      }
  
      public void setFullname(String fullname) {
          this.fullname = fullname;
      }
  
      public String getPhone() {
          return phone;
      }
  
      public void setPhone(String phone) {
          this.phone = phone;
      }
  
      public String getImageurl() {
          return imageurl;
      }
  
      public void setImageurl(String imageurl) {
          this.imageurl = imageurl;
      }
  
      public String getBio() {
          return bio;
      }
  
      public void setBio(String bio) {
          this.bio = bio;
      }
  }
  </code></pre>