Look friend.... Maybe the error is at the time of Instantiating the class that stores the Firebase data.
Example:
Imagine you have the following class as in the answer above:
public class Usuario {
private string id;
private string email;
private string password;
private string name;
private string cpfCnpj
Private String telephone;
private string address;
int private credit;
public Usuario() {
}
public Usuario(String id, String email, String senha, String nome, String cpfCnpj, String telefone, String endereco, int credito) {
this.id = id;
this.email = email;
this.senha = senha;
this.nome = nome;
this.cpfCnpj = cpfCnpj;
this.telefone = telefone;
this.endereco = endereco,
this.credito = credito;
}
}
// With their respective geters and seters
Imagine that you are in Activity1 and in it you call "User user = new User()" to record data coming from Firebase.
Then you go to Activity2 and there you want to set the "Email" saved in the User class".
To do this, you instantiate again the class "User user = new User(); and apply no to your textView the value of the "User class email" >> textView.setText(user.getEmail)
If that is your case, perhaps the error lies there!
When you instantiate the User class in Activity2 again, the values stored in the Strings and int disappear and with that your textView will appear empty.
To solve this problem, because I faced the same problem, I did so in my User class:
public class Usuario {
private Static String id;
private Static String email;
private Static String password;
private Static String name;
private Static String cpfCnpj
private Static String phone;
private Static String addressee;
private Static int credit;
// > See that here I add my Strings and the int the "Static".
// > This causes the values applied to it not to be lost regardless of how many times I instate my User class.
// > The value will only change if you change it manually.
public Usuario() {
}
public Usuario(String id, String email, String senha, String nome, String cpfCnpj, String telefone, String endereco, int credito) {
this.id = id;
this.email = email;
this.senha = senha;
this.nome = nome;
this.cpfCnpj = cpfCnpj;
this.telefone = telefone;
this.endereco = endereco,
this.credito = credito;
}
}
// Getters and setters should remain as listed below without change. Even if Strings and int are static:
public String getId() {
Return id;
}
public void setId(String id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getCpfCnpj() {
return cpfCnpj;
}
public void setCpfCnpj(String cpfCnpj) {
this.cpfCnpj = cpfCnpj;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public int getCredito() {
return credito;
}
public void setCredito(int credito) {
this.credito = credito;
}
"String.valueOf(dataSnapshot.getValue())" returns some value?
– porthfind
Does not return no
– Paiva
Show your class Configuracaofirebase, pf
– Rosário Pereira Fernandes
https://pastebin.com/HYT8dBps
– Paiva