title: sending data of two fragments to firebase (Fragment wise or in one go)
body: <p>I have two fragments in one activity. In the first fragment, I have fields like name, email, gender and phone number and by the next button replace with second fragment and on the second fragment, I have a password and confirm password fields. Now I want to send data to firebase fragment-wise or send data of two fragments at one time(by pressing the register button which is on the second fragment).but did not know how to do that</p>
  <p>//First Fragment</p>
  <pre><code>    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;
      android:background=&quot;@color/purple_200&quot;
      tools:context=&quot;.CustomerRegisterFragment&quot;&gt;
      &lt;ImageView
          android:id=&quot;@+id/imageView&quot;
          android:layout_width=&quot;131dp&quot;
          android:layout_height=&quot;46dp&quot;
          android:src=&quot;@drawable/logo&quot;
          android:textAlignment=&quot;center&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.18&quot;
          tools:ignore=&quot;MissingConstraints&quot;
          android:contentDescription=&quot;TODO&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textViewCustomerDetails&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:fontFamily=&quot;@font/courbd&quot;
          android:text=&quot;@string/personal_details&quot;
          android:textColor=&quot;@color/black&quot;
          android:textSize=&quot;24sp&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.28&quot;
          tools:ignore=&quot;MissingConstraints&quot; /&gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/linearLayout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.439&quot;
          tools:ignore=&quot;MissingConstraints&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/textViewUserName&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginEnd=&quot;8dp&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_name&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editTextUserName&quot;
              android:layout_width=&quot;282dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;30dp&quot;
              android:backgroundTint=&quot;@color/black&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:inputType=&quot;textPersonName&quot;
              android:paddingBottom=&quot;4dp&quot;
              android:singleLine=&quot;true&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/linearLayout1&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;10dp&quot;
          android:orientation=&quot;horizontal&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          tools:ignore=&quot;MissingConstraints&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/textViewUserEmail&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_email&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editTextUserEmail&quot;
              android:layout_width=&quot;282dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;30dp&quot;
              android:backgroundTint=&quot;@color/black&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:inputType=&quot;textEmailAddress&quot;
              android:paddingBottom=&quot;4dp&quot;
              android:singleLine=&quot;true&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/linearLayout2&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/linearLayout1&quot;
          tools:ignore=&quot;MissingConstraints&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/textViewUserPhone&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;Phone #:&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editTextUserPhone&quot;
              android:layout_width=&quot;282dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;10dp&quot;
              android:backgroundTint=&quot;@color/black&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:inputType=&quot;phone&quot;
              android:paddingBottom=&quot;4dp&quot;
              android:singleLine=&quot;true&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/linearLayout3&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/linearLayout2&quot;
          tools:ignore=&quot;MissingConstraints&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/textViewUserGender&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginEnd=&quot;15dp&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_gender&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;CheckBox
              android:id=&quot;@+id/male&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:buttonTint=&quot;@color/black&quot;
              android:checked=&quot;true&quot;
              android:clickable=&quot;false&quot;
              android:focusableInTouchMode=&quot;true&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_gender_male&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
          &lt;CheckBox
              android:id=&quot;@+id/female&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:buttonTint=&quot;@color/black&quot;
              android:checked=&quot;false&quot;
              android:clickable=&quot;false&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_gender_female&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
          &lt;CheckBox
              android:id=&quot;@+id/other&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:buttonTint=&quot;@color/black&quot;
              android:checked=&quot;false&quot;
              android:clickable=&quot;false&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:text=&quot;@string/user_gender_other&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;androidx.appcompat.widget.AppCompatButton
          android:id=&quot;@+id/btnRegisterCustomer&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;71dp&quot;
          android:layout_marginBottom=&quot;120dp&quot;
          android:background=&quot;@drawable/button_style&quot;
          android:text=&quot;@string/btn_next&quot;
          android:textAllCaps=&quot;false&quot;
          android:textColor=&quot;@color/black&quot;
          android:textSize=&quot;18sp&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/linearLayout3&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
   
  </code></pre>
  <p>//Second Fragment</p>
  <pre><code>            &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:background=&quot;@color/purple_200&quot;
      tools:context=&quot;.CustomerRegisterFragment1&quot;&gt;
      &lt;ImageView
          android:id=&quot;@+id/imageView&quot;
          android:layout_width=&quot;131dp&quot;
          android:layout_height=&quot;46dp&quot;
          android:src=&quot;@drawable/logo&quot;
          android:textAlignment=&quot;center&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.18&quot;
          tools:ignore=&quot;MissingConstraints&quot;
          android:contentDescription=&quot;TODO&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textViewCustomerPassTitle&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:fontFamily=&quot;@font/courbd&quot;
          android:text=&quot;@string/c_password&quot;
          android:textColor=&quot;@color/black&quot;
          android:textSize=&quot;24sp&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.28&quot;
          tools:ignore=&quot;MissingConstraints&quot; /&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:id=&quot;@+id/CustomerRegisterFragment1.linearLayout&quot;
          android:layout_centerVertical=&quot;true&quot;
          android:layout_marginBottom=&quot;288dp&quot;
          android:orientation=&quot;vertical&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintHorizontal_bias=&quot;0.0&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/textViewCustomerPassTitle&quot;
          tools:ignore=&quot;MissingConstraints&quot;&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editTextCustomerPassword&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:backgroundTint=&quot;#695547&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:hint=&quot;@string/customer_password&quot;
              android:inputType=&quot;textPassword&quot;
              android:textColor=&quot;@color/black&quot;
              android:textColorHint=&quot;#A88973&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editTextCustomerConfirmPassword&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:backgroundTint=&quot;#695547&quot;
              android:fontFamily=&quot;@font/courbd&quot;
              android:hint=&quot;@string/cconfirm_password&quot;
              android:inputType=&quot;textPassword&quot;
              android:textColor=&quot;@color/black&quot;
              android:textColorHint=&quot;#A88973&quot; /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;androidx.appcompat.widget.AppCompatButton
          android:id=&quot;@+id/btnRegisterCustomer&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;67dp&quot;
          android:layout_marginBottom=&quot;123dp&quot;
          android:background=&quot;@drawable/button_style&quot;
          android:text=&quot;@string/btn_register_client&quot;
          android:textAllCaps=&quot;false&quot;
          android:textColor=&quot;@color/black&quot;
          android:textSize=&quot;18sp&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintHorizontal_bias=&quot;0.498&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/CustomerRegisterFragment1.linearLayout&quot;
          app:layout_constraintVertical_bias=&quot;0.229&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; 
  </code></pre>