title: Extract single data value from retrieved firebase json objects
body: <p>In my android app I want to retrieve only a single value from all the nodes of firebase json objects and check...
  My firebase database looks like ->
  <a href="https://i.stack.imgur.com/nYBZI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nYBZI.png" alt="enter image description here"></a></p>
  
  <p>Now i am using this code to achieve my task but I am getting null everytime  as output..</p>
  
  <pre><code>public class optChos extends AppCompatActivity {
  DatabaseReference ref;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_opt_chos);
  
      final FirebaseDatabase database = FirebaseDatabase.getInstance();
      ref = database.getReference("vendorDtl");
  }
  
  public void fetchkey(View view) {
      EditText etx=findViewById(R.id.etkey);
      String keysrch=etx.getText().toString();
      Log.i("optionchoose","fetchkeycalled");
      Toast.makeText(getApplicationContext(),"Key finfing",Toast.LENGTH_SHORT).show();
  
  
      ref.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for(DataSnapshot vst:dataSnapshot.getChildren()) {
                  vendor vn = vst.getValue(vendor.class);
                  Toast.makeText(getApplicationContext(), "Email is-&gt; " + vn.getNam(), Toast.LENGTH_SHORT).show();
                  Toast.makeText(getApplicationContext(), "key is-&gt; " + vn.getVky(), Toast.LENGTH_SHORT).show();
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
              Toast.makeText(getApplicationContext(),"nothing fetched",Toast.LENGTH_SHORT).show();
          }
      });
  }
  
  
  
  @Override
  protected void onStart() {
      super.onStart();
      ref.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for(DataSnapshot vst:dataSnapshot.getChildren()) {
                  vendor vn = vst.getValue(vendor.class);
                  Toast.makeText(getApplicationContext(), "Email is-&gt; " + vn.getNam(), Toast.LENGTH_SHORT).show();
                  Toast.makeText(getApplicationContext(), "key is-&gt; " + vn.getVky(), Toast.LENGTH_SHORT).show();
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
              Toast.makeText(getApplicationContext(),"nothing fetched",Toast.LENGTH_SHORT).show();
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here <code>fetchkey(View view)</code> is the onclick function of a button..</p>
  
  <blockquote>
    <p>I want to retrieve that <code>vid</code> from every node and check with a user
    entered value ..How can i do that?</p>
  </blockquote>