title: Android Firebase, getKey of specific value in database
body: <p>I have been searching for a few days, but couldn't find the solution for my problem.</p>
  
  <p>I would like to get the key of the value that is selected in the spinner. The spinner contains an arraylist of the names in the database.</p>
  
  <pre><code>Button Testing = (Button)findViewById(R.id.Testing);
      Testing.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              p1ID = playerOneSpinner.getSelectedItem().toString();
  
              DatabaseReference db = (DatabaseReference) 
              FirebaseDatabase.getInstance().getReference().child("id");
  
              db.addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      for (DataSnapshot val : dataSnapshot.getChildren()){
                          data = val.toString();
  
                          Log.e("HALLO", data);
                      }
                  }
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
  
                  }
              });
  
              Log.e("HALLO", p1ID + " &lt;-- this is the spinner");
  
          }
      });
  </code></pre>
  
  <p>This is how my database lookslike</p>
  
  <pre><code>LadderCompetition
     - id
          -1
             Jeroen
          -2
             Franky
          -3
             Jesper
          -4
             Rob
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JepD0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JepD0.png" alt="OutPut"></a>
  <a href="https://i.stack.imgur.com/YRf9H.png" rel="nofollow noreferrer">output of logcat</a></p>