For example I have defined a custom object called Subject with fields (name- age...) and on firestore the documents have the same format (name -age..). To get document I use :
SubjectReference.document(document.getId()).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
Subjectt subjectt = task.getResult().toObject(Subjectt.class);
} else {
Log.i("selected", "No such document");
}
} else {
Log.i("selected", "get failed with ", task.getException());
}
}
});
What I want is I want to use this object from within the activity/fragment. However I cannot make the funtion return the object Subject. Is there any other way to do it?
Is it possible to get a document in firestore as custom object to use it in android activity?