0

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!

  • This seems to be a similar issue to [this question](https://stackoverflow.com/questions/44990764/why-should-i-transform-myvariable-to-final-one-element-array) – Micah Nov 04 '21 at 19:55

0 Answers0