Q:

Android String Comparison Not Working

I am having hard time comparing two strings in Android using Java, what I am doing is running HTTP get request which return yes or no and based on that I decide whether to launch a new activity or not.
I am performing the string comparison inside Async onPostExecute method and though the HTTP returned string is yes it is not working for me. 
Here goes the code
        protected void onPostExecute(String result) {
        progressDialog.dismiss();
        if(result.equals("yes"))
        {
            Intent toDashboard = new Intent(LoginActivity.this,Dashboard.class); 
            startActivity(toDashboard);
            Toast.makeText(LoginActivity.this, "It was yes", Toast.LENGTH_LONG).show();
        }
        else
        {
            Toast.makeText(LoginActivity.this, result, Toast.LENGTH_LONG).show();
        }
    }

Though the returned string is yes it still skips the if statement and creates a toast showing "Yes".
I have also tried some other ways to match a string and they all goes here
if(result == "yes")
if(result.toString().equals("yes"))
if(result.contentEquals("yes"))
if(result.equalsIgnoreCase("yes"))

None of them works for me

A:

There might be some white space in result.
Try trimming it.
result.trim().equals("yes")

