0
I need to add the fields of my bank Firebase, that is the field Receita
that is inside the collection Dados
follows the picture below:
I am using the following code to make a simple read, sets to read the recipe field that is within the collection Dados
in the document 3954d8bf-8796-4955-9d7c-0f245dcbbfdf
public class TelaCentral extends AppCompatActivity {
FirebaseAuth firebaseAuth;
FirebaseUser firebaseUser;
FirebaseFirestore db = FirebaseFirestore.getInstance();
DocumentReference dados = db.document("Dados/3954d8bf-8796-4955-9d7c-0f245dcbbfdf");
TextView emailExibe,campoReceita;
Button buttonSair;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_telacentral);
firebaseAuth = FirebaseAuth.getInstance();
firebaseUser = firebaseAuth.getCurrentUser();
Leitura();
}
// LEITURA
private void Leitura(){
dados.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists()){
String recei = documentSnapshot.getDouble("Receita").toString();
campoReceita.setText(recei);
}
}
});
}
}
However, I would like to go through all the Documentos
that are in the collection Dados
and add the field Receita
to display to the user, how could it do this?
Are you making a mistake? What’s going on? Only the first is returning?
– Tmilitino
pq recipe is a string? should be decimal
– rray