== and .equals() not working in java [duplicate]

Replace: if (packageName != sysName)

With: if (!packageName.equals(sysName.toString()))

Also, you have a ; at the end of if which shouldn’t be there. (Here: if (packageName.equals(sysName.toString())) ;)

Actually, to form your condition better, you should have an if-else block instead of 2 ifs.

something like:

if (packageName.equals(sysName.toString())){
    Log.d("", "IT MATCHES");
} else {
    Log.d("", "NOPE DOESNT MATCH");
}

Leave a Comment