I create a variable 'currentUserName' and when I use it onDataChange method I get this error: "Transform 'currentUserName' into final one element array" here my code:
String currentUserName = "";
FirebaseDatabase.getInstance().getReference().child("Users").child(currentUserID).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
currentUserName = snapshot.child("userName").getValue(); // here the error
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
I don't understand the error!