title: How to set key value to spinner list from firebase
body: <p><a href="https://i.stack.imgur.com/9odHd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9odHd.jpg" alt="I have database like this"></a></p>
  
  <p>I have spinner and i want to add key value from firebase to set on spinner list .I use code below but not working for me.</p>
  
  <p>I want to add keys value(2015-16,2016-17,2017-18) in spinner.</p>
  
  <p>Here my code it's not working.</p>
  
  <pre><code>  DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
      rootRef.child("First").addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
  
              final List&lt;String&gt; sess = new ArrayList&lt;String&gt;();
  
              for (DataSnapshot areaSnapshot: dataSnapshot.getChildren()) {
                  String Session = areaSnapshot.getKey();
                  sess.add(Session);
              }
  
              Spinner spinner = (Spinner) findViewById(R.id.spinner3);
              ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(AdminMain.this, android.R.layout.simple_spinner_item, sess);
              adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              spinner.setAdapter(adapter);
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  </code></pre>