title: How to return a value from OnCompleteListener while creating user with email and password in Firestore?
body: <p>The code which I am trying to write is</p>
  
  <pre><code>private String val;
      public String checkEmail(){
  
          FirebaseFirestore db = FirebaseFirestore.getInstance();
          db.collection("cities").whereEqualTo("cities", "Boston").get()
                  .addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; task) {
                          if (task.isSuccessful()){
                              val = "City exists";
                          }else{
                              val = "City does not exist";
                          }
                      }
                  });
          return val;
      }
  
  
  </code></pre>
  
  <p>This code returns <code>val</code> as <code>null</code> instead of the values. How can this problem be solved?</p>