Hi I have problem with my code.
final String range = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
SecureRandom sr = new SecureRandom();
randomString(8, range, sr);
String code = randomString(8, AB, rnd);
Log.d(TAG, code);
Query codeQuery = collectionReference.whereEqualTo("ReferenceCode", code);
codeQuery.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
if (document.exists()) {
String refCode = document.getString("ReferenceCode");
Log.d(TAG, "this code already exists");
} else {
Log.d(TAG, "this code does not exists");
}
}
} else {
Log.d("TAG", "Error getting documents: ", task.getException());
}
}
});
What I want to do is after (document.exists())
just repeat generating and checking existing the same code in database (so all above code).
How I can do this ?
Aucun commentaire:
Enregistrer un commentaire