this is a basic knowledge but I get frustrated after 3 hours of trying. I am running codes in Android Studio and I just want to compare the result of 2 strings This is my codes
String result=stringBuilder.toString();
String wanted="SUCCESS";
if(result.equalsIgnoreCase("SUCCESS"))
{
Log.d("RESULT","FINALLY 1");
}
else if(result.equals("SUCCESS")) {
Log.d("RESULT", "FINALLY 2");
}
else if(result=="SUCCESS")
{
Log.d("RESULT","FINALLY 3");
}
else if("SUCCESS".equals(result))
{
Log.d("RESULT","FINALLY 4");
}
else if(result.equals(wanted))
{
Log.d("RESULT","FINALLY 5");
}
else
{
Log.d("RESULT",result);
}
I have tried every options available on webs but I got the same results and you can see that var "result" is "SUCCESS"
11-11 23:31:01.477 8116-8152/com.example.asus.ucomm D/RESULT﹕ SUCCESS
What did I do here that get errors from just comparing strings? Am I too tired until I missed something? Please help.
//EDIT I get stringBuilder.toString() to get the response from my PHP file. This is the last code that checks the database
if(isset($_GET['user']))
{
$findFriend=$_GET['user'];
$sql = "SELECT * FROM username WHERE pin='$findFriend'";
}
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
echo "SUCCESS";
}
else echo "NOT FOUND";
//EDIT 2 The result before trim() is
11-12 00:07:56.057 6000-6036/com.example.asus.ucomm D/RESULT﹕ +SUCCESS
+
I thought that it ran out of space. But it had /n