This is the code that I'm using:
ref.get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Log.d(TAG, "DocumentSnapshot data: " + document.getData());
}
}
});
And this how Android Studio highlights the error:
As I understand from this answer:
A successfully completed task will never pass
null
for theDocumentSnapshot
.
How can I solve this without checking for nullity? Thanks!