I'm trying to implement a function retrieve() that will retrieve data from the database, however I cannot stop the execution of the main function, i.e, the function calling retrieve(), until retrieve() finishes execution.
The function I'm trying to implement is:
public void retrieve(final Qu qu) {
        db.collection(COLLECTION).document("someDoc")
            .get()
                .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task) {
                        if (task.isSuccessful()) {
                                DocumentSnapshot doc = task.getResult();
                                ques.setQu(q.toObject(Qu.class));
                                }
                            }
                        }
                    }
                }).;
    }
Appreciate the help.
 
    