0

sorry for this silly question but I am going insane, it's a simple if statement inside OnChildEventListener to exclude the current user results from my gridView as Firebase doesn't apparently have notEqualTo() method. However, the if statment doesn't seem to give me correct result when it should be true. Please see below :

 String name = "eee";   //setting a username just a test for here
 databaseRef.addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {  


        if (String.valueOf(dataSnapshot.child("username").getValue()) == name) {

                GridItem item = dataSnapshot.getValue(GridItem.class);
                mGridData.add(item);
                mGridAdapter.setGridData(mGridData);

            }
        }

I log the String value of what I have inside my if statment and it logs out as eee , now why doesn't this if statement result in true? I would appreciate if someone tells me what I am missing? if I simply do if(true) or any other string inside, it works!

Appreciate the help.

TheBen
  • 3,410
  • 3
  • 26
  • 51

0 Answers0