android - trouble comparing two string variables with different refrences -
i trying check user's inserted password saved password in database.
methode:
private boolean checkpassword() { textview txt_pass = (textview) findviewbyid(r.id.login_password_txt); string _writtenpassword = txt_pass.gettext().tostring().trim(); if (_writtenpassword == userpassword) return true; log.d(tag, userpassword); log.d(tag, _writtenpassword); log.d(tag, string.valueof(userpassword.length())); log.d(tag, string.valueof(_writtenpassword.length())); return false; }
the log shows me password , length.
result is:
123 123 3 3
but methode returns false!!!
can me please?
try this..
string should compares .equals("")
if (_writtenpassword.equals(userpassword)) return true;
==
compares 2 references
refer string comparison
Comments
Post a Comment