I am using EditText with android:password="true" so that the user enters a password. Then I want to compare the password with a hard-coded password when the user clicks a button.
But I can not compare the password with the string "mypassword". Here is the code I use to verify the password:
EditText pw = (EditText) findViewById(R.id.pwdTxt); if(pw.getText().equals("mypassword")) { Intent i = new Intent(LoginActivity.this, LinkpageActivity.class); startActivity(i); } else {
Comparing pw.getText().equals("mypassword") returns false even if I find the correct password. How to check password using EditText ?
source share