resultString is the parameter I get from sqlite
resultString = result.getString(result.getColumnIndex(1));
I want to compare ignore case with user input , following is the code I have use. But it doesn't work.
For example, in database, I store a username "George" When I login, I have to type exactly "George"."george" doesn't work.
Here is my code to compare.
if (userName.equalsIgnoreCase(resultString)) {
return true;
}
What might be the problem?
Please try following code,
if (userName.trim().equalsIgnoreCase(resultString.trim()))
{
return true;
}
Your code should work if the only difference is the case. I suspect you have leading or trailing spaces. Try the following:
if (userName.trim().equalsIgnoreCase(resultString.trim())) {
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With