title: HttpClient with Android
body: <p>I have interesting problem which I have been tried to figure out for 3 hours.. I'm making a login page in Android. I'm sending the values which are username and password with HttpClient to my PHP page and I take true result until see some code that is below.</p>
  
  <pre><code>button_login_submit.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  ArrayList&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();
                  postParameters.add(new BasicNameValuePair("username", et_username.getText().toString()));
                  postParameters.add(new BasicNameValuePair("password", et_password.getText().toString()));
  
                  String response = null;
                  try 
                  {
                      response = CustomHttpClient.executeHttpPost("http://10.0.2.2/corner1/login.php", postParameters);
                      String res=response.toString();
                      //here, the value of "res" variable is the exactly what I want. 
                      if(!res.equals("0")) // but in here, the value of "res.equals("0")" is always false. So  the value of inside if is always true!! but why????
                      {
                          if(!res.equals("01"))
                          {
                              tv_login_error.setText("Success");
                              Intent main_page = new Intent(getApplicationContext(), Main_Activity.class);
                              main_page.putExtra("id",res);
                              //startActivity(main_page);
                              //finish();
                          }
                          else
                          {
                              tv_login_error.setText("False Username or Password");
                          }
                      }
                      else
                      {
                          tv_login_error.setText("Please try again using your full usurname or password ");
                      }
                  } 
                  catch (Exception e) 
                  {
                      tv_login_error.setText(e.toString());
                  }
              }
          }); 
  </code></pre>
  
  <p>If the variable of "res" is "0", which means there are some empty value. If it is "01" there are no user, and otherwise the PHP page send me the id of user.
  Why "res.equals("0") is always false???</p>
  
  <p>PROBLEM SOLVED!!!!
  the problem is that the value of res which is coming from the code of <code>String res=response.toString();</code> is coming with "\n". so when you want to compare values, you have to add "\n" end of the word. for example <code>res.equals("0\n")</code></p>