I've been working on an app, and in a certain activity, a if statement seems to never equal true but I can't figure out why. I suppose it has something to do with the SharedPreferences. Could someone take a look at my code and see why this is happening so I could prevent it later on while typing more complex code?
This is the activity I'm having trouble with:
public class SignInActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_main3);
        SharedPreferences example = getSharedPreferences("label", 0);
        final String username = example.getString("username", "nothing found");
        final Button LogInButton = (Button) findViewById(R.id.LoginButton);
        LogInButton.setOnClickListener(
                new Button.OnClickListener(){
                    public void onClick(View v){
                        EditText userNameInput = (EditText) findViewById(R.id.UsernameLogIn);
                        String userString = userNameInput.getText().toString();
                        if (username == userString){
                            Intent nextScreen = new Intent(getApplicationContext(), MainActivity.class);
                            startActivity(nextScreen);
                        }
                    }
                }
        );
    }
}
 
    