-2

please do not mark this question as duplicate, because I have all of the solutions on similar questions to this, and they haven't worked. Not saying that those answers were wrong, just that it isn't working for me at least. Thanks.

Here is my if statement:

                if (dataSnapshot.exists() && !dataSnapshot.child("connections").child("nope").hasChild(currentUId) && !dataSnapshot.child("connections").child("yes").hasChild(currentUId)){
                String profileImageUrl = "default";
                if (profileImageUrl !=null && !dataSnapshot.child("profileImageUrl").getValue().equals("default")){
                    profileImageUrl = dataSnapshot.child("profileImageUrl").getValue().toString();
                }
                com.example.tiarnan.tinder.cards item = new com.example.tiarnan.tinder.cards(dataSnapshot.getKey(), dataSnapshot.child("name").getValue().toString(), profileImageUrl);
                rowItems.add(item);
                arrayAdapter.notifyDataSetChanged();
            }

As you can see, I did try to put a != null, but it still isn't working. That was the most seen solution on the duplicate questions.

Thanks in advance, and I hope you guys can help me solve this.

maddeveloper123
  • 47
  • 2
  • 11

1 Answers1

0

You just set profileImageUrl the line before, so checking if it is null doesn't do anything. The null check you need to make is -

if (dataSnapshot.child("profileImageUrl").getValue() != null)
bmcglynn
  • 145
  • 2
  • 6