I have a query in Firebase that should return user data to verify that it still has access and its level of access to the system, however when modifying the values the query continues to bring the previous values.
private void buscarUser(String matricula){
ValueEventListener buscaUserListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(!dataSnapshot.exists()){
Toast.makeText(BuscaUserPage.this,
"Usuário não encontrado.", Toast.LENGTH_LONG).show();
}else {
try {
Usuario userRecebido = null;
for (DataSnapshot dados : dataSnapshot.getChildren()) {
userRecebido = dados.getValue(Usuario.class);
idUser = dados.getKey();
}
atualizarTela(userRecebido);
}catch (Exception e){
Toast.makeText(BuscaUserPage.this,
e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(BuscaUserPage.this,
"Ocorreu um erro: " + Objects.requireNonNull(databaseError),
Toast.LENGTH_LONG).show();
}
};
Query consulta = referenciaFirebase.child("Usuarios").orderByChild("matricula").equalTo(matricula);
consulta.addListenerForSingleValueEvent(buscaUserListener);
}
User class:
public class Usuario implements Serializable {
private String id;
private String email;
private String senha;
private String matricula;
private int nivelAcesso;
private boolean ativo;
}
The Active and active level values that are changed.