title: How to implement search button to android Firebase database?
body: <p>I tried so many time to implement to search my android Firebase database.<br>
  Query: <code>query = dateRef.orderByChild("phone").equalTo(searchPhoneNumber);</code><br>
  I don't know how to set searchPhoneNumber in EditText  value. But I know EditText and one button using to search phone numbers. But I need Java code. Eg: if I enter phone numbers in EditText and I press button, after I get a output in same page.<br>
  Here I attached my Firebase screenshot and my code.</p>
  
  <p><strong>Firebase database screenshot</strong></p>
  
  <p><a href="https://i.stack.imgur.com/YFj83.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YFj83.jpg" alt="enter image description here"></a></p>
  
  <p><strong>java</strong>  </p>
  
  <pre><code>public class ViewProduction extends AppCompatActivity {
  
  private RecyclerView mRecyclerView;
  private Adapater mAdapter;
  
  private ProgressBar mprogress;
  
  private DatabaseReference mDatabaseRef;
  private List&lt;Datastore&gt; mUploads;
  
  
  EditText edit;
  Button btnsearch;
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_view_production);
  
  
      getSupportActionBar().setDisplayShowHomeEnabled(true);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
  
      edit =(EditText)findViewById(R.id.edit);
  
      btnsearch = (Button)findViewById(R.id.btnsearch);
  
  
  
      ActionBar actionBar = getSupportActionBar();
      actionBar.setTitle("Production Details");
  
      mRecyclerView = findViewById(R.id.recyclerj);
      mRecyclerView.setHasFixedSize(true);
  
      mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  
      mprogress = findViewById(R.id.progress);
  
      mUploads = new ArrayList&lt;&gt;();
  
      mDatabaseRef = FirebaseDatabase.getInstance().getReference("Rajadriving");
  
      btnsearch.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              // called search() method on button click.
              search();
          }
      });
  
  public void search(){
      edit.addTextChangedListener(new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
          }
  
          @Override
          public void afterTextChanged(Editable s) {
  
              DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
  
              DatabaseReference dateRef = rootRef.child("Rajadriving").child("9-6-2018");
              Query query = dateRef.orderByChild("phone").equalTo(s.toString());
  
              query.addListenerForSingleValueEvent(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                          Datastore upload = postSnapshot.getValue(Datastore.class);
                          mUploads.add(upload);
                      }
                      mAdapter = new Adapater(ViewProduction.this, mUploads);
  
                      mRecyclerView.setAdapter(mAdapter);
                      mAdapter.notifyDataSetChanged();
                      mprogress.setVisibility(View.INVISIBLE);
                  }
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
                      Toast.makeText(ViewProduction.this, databaseError.getMessage(),Toast.LENGTH_SHORT).show();
                      mprogress.setVisibility(View.INVISIBLE);
                  }
              });
          }
      }
  }
  
  
  
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      int id = item.getItemId();
  
      if (id == android.R.id.home){
          this.finish();
      }
      return super.onOptionsItemSelected(item);
  }
  
  }
  </code></pre>
  
  <p><strong>xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  tools:context="com.udayaj.rajadriving.ViewProduction"&gt;
  
  &lt;EditText
      android:id="@+id/edit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignEnd="@+id/progress"
      android:layout_alignParentTop="true"
      android:layout_alignRight="@+id/progress"
      android:hint="enter phone" /&gt;
  
  &lt;Button
      android:id="@+id/btnsearch"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/recyclerj"
      android:layout_marginLeft="21dp"
      android:layout_marginStart="21dp"
      android:layout_toEndOf="@+id/edit"
      android:layout_toRightOf="@+id/edit"
      android:text="Search" /&gt;
  
  
      &lt;ProgressBar
          android:id="@+id/progress"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"/&gt;
  
  
      &lt;android.support.v7.widget.RecyclerView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/table01"
          android:scrollbars="vertical"
          android:id="@+id/recyclerj"&gt;
      &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>