comparison of two Strings doesn't work in android [duplicate]

Use string1.equalsIgnoreCase("something) or .equals("Something");

With == (for strings) in java you are comparing they are of same reference. Like you did is the test if both of them are strings objects.


In java, a==b is used to compare 2 references, not the objects themselves.

so if you have 2 strings that you want to compare, use the equals() method on String. for eg

boolean resultOfComparison=stringA.equals(stringB);

Use

entry_tag.equals(dangerous)

you're comparing actual String objects, not their content. In Java, operators are not overloaded so == can't be used to compare strings.