I'm using firebase realtime database and as far I know, you have to use the
DatabaseReference.addValueEventListener
to read a value from the firebase database.
Here addValueEventListener
is asynchronous by default. I need to read it synchronously. For FireBase storage, for the same issue while uploading files, I could make the process synchronous by using
UploadTask.TaskSnapshot await = Tasks.await(uploadTask);
Instead of using
uploadTask.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
}
})
Is there any similar synchronous alternative for addValueEventListener
like shown above?