All of the text in an application I'm working on is stored inside FireStore documents, so to retrieve it I use this bit of code
db.collection("language").document("kCreateNewAccount").get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
String viewText = lan.equals("en") ? documentSnapshot.getString("en")
: documentSnapshot.getString("es");
createAccount.setText(viewText);
}
});
I've tried to put it into a function that takes the document name as a parameter and returns the correspondent string to avoid writing the same thing over and over again, to no avail, any help is welcome