I am new to android development and firestore. What I am trying to do is compare whether a string exists in the database or not. However, the query always returns true even if I am trying to compare with string that is not present in the database. Here is my code:
public void loadData(View v){
db.collection("Machines")
.whereEqualTo("machineId","AYSLE004")
.get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
//MachineId exists
Toast.makeText(MainActivity.this, "Machine Id exists", Toast.LENGTH_LONG).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override …Run Code Online (Sandbox Code Playgroud)