title: To use spinner to select node
body: <p>I created a spinner with option customer and driver in my signup page
  and this is my code</p>
  <pre><code>public class SignUp extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
      ActivitySignUpBinding binding;
      private FirebaseAuth mAuth;
      FirebaseDatabase database;
      ProgressDialog progressdialog;
      private Spinner spinner;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          binding=ActivitySignUpBinding.inflate(getLayoutInflater());
          setContentView(binding.getRoot());
          spinner=findViewById(R.id.spinner3);
          ArrayAdapter&lt;CharSequence&gt; adapter=ArrayAdapter.createFromResource(this,R.array.Options, android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner.setAdapter(adapter);
          spinner.setOnItemSelectedListener(this);
          mAuth = FirebaseAuth.getInstance();
          database=FirebaseDatabase.getInstance();
          progressdialog=new ProgressDialog(SignUp.this);
          progressdialog.setTitle(&quot;Creating Account&quot;);
          progressdialog.setMessage(&quot;pls wait while we create your account&quot;);
          binding.SignUp.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  progressdialog.show();
                  mAuth.createUserWithEmailAndPassword(binding.Email.getText().toString()
                          ,binding.Password.getText().toString()).addOnCompleteListener(new OnCompleteListener&lt;AuthResult&gt;() {
                      @Override
                      public void onComplete(@NonNull  Task&lt;AuthResult&gt; task) {
                          progressdialog.dismiss();
                          if (task.isSuccessful()) {
                              Users user=new Users(binding.Username.getText().toString(),binding.Email.getText().toString(),binding.Password.getText().toString());
                              Toast.makeText(SignUp.this, &quot;Account created&quot;, Toast.LENGTH_SHORT).show();
                              String id=task.getResult().getUser().getUid();
                                      database.getReference().child(&quot;Users&quot;).child(&quot;Driver&quot;).child(id).setValue(user);
                              
                          }
                          else {
                              Toast.makeText(SignUp.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                          }
  
                      }
                  });
              }
          });
  
  
      }
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          String text=parent.getItemAtPosition(position).toString();
          Toast.makeText(parent.getContext(),text,Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
      }
  }
  </code></pre>
  <p>I wanted to know how to access the variable text from 2nd last overide to the part where i am adding the values to nodes
  the part where i wrote</p>
  <pre><code>database.getReference().child(&quot;Users&quot;).child(&quot;Driver&quot;).child(id).setValue(user);
  </code></pre>
  <p>i actually want to put it in if-else clause so tht if the option selected in spinner is not driver
  then it goes to .child(&quot;customer&quot;)</p>