Comparing strings in android
<p>I want to compare a string literal that is "failed" to a string that has been passed to this function, but my problem is that the string that is passed "result" is not the same as the string fail, and i explicitly passed "failed" to the function. </p>

<pre><code>       if(result.equals(fail))
</code></pre>

<p>always returns false for me</p>

<pre><code>protected void onPostExecute(String result) {
 super.onPostExecute(result);   
 TextView data_details = (TextView)findViewById(R.id.results_tab);
 data_details.setText(result); // THIS PRINTS OUT THE VALUE TO SCREEN WHICH IS 'failed'
 String fail = "failed";

 if(result.equals(fail))
 {

    Intent redirect = new Intent(LogActivity.this, MainActivity.class);
    redirect.putExtra("error", result);
    startActivity(redirect);
    finish();
  }     
 }
</code></pre>

<p>And also I tried:</p>

<pre><code>if(result.equalsIgnoreCase("failed"))
</code></pre>
