Unusual logical android operator does not work comparing two strings


I'm trying a simple check. If a string name locale has "es" as value.

public String locale =

// ...

Log.v(tag, "Idioma del sistema: «" + locale +"»");
if (locale != "es") {
        "We are sorry that this tool is only available in Spanish " +
        "language. See Author menu item for more information. [" +
        locale + "]");
    locale = "en";

adb logcat shows "es" as content of string "locale" but code inside the condition is being executed.

It seem that problem is not of android or of logic this is in JAVA. Try this and tell us what is happening

   //Your Code