title: Error NullPointerException: lock == null
body: <p>Can anyone help me with this error please, Select Values from MySQL Database to Android when i run app and search for ID, It always said (Invalid IP Address)...</p>
  
  <p>I have a PHP file on my web server that connects to a WampServer database and retrieves values that are returned to Android app..</p>
  
  <pre><code>String id
  String name;
  InputStream is=null;
  String result=null;
  String line;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      final EditText e_id=(EditText) findViewById(R.id.editText1);
      Button select=(Button) findViewById(R.id.button1);
      select.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
          id=e_id.getText().toString();
          select();
      }
  });
  }
  
  public void select()
  {
      ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
  
  nameValuePairs.add(new BasicNameValuePair("id",id));
  
      try
      {
      HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new HttpPost("http://10.0.2.2/test/select.php");
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = httpclient.execute(httppost); 
          HttpEntity entity = response.getEntity();
          is = entity.getContent();
          Log.e("pass 1", "connection success ");
  }
      catch(Exception e)
  {
          Log.e("Fail 1", e.toString());
          Toast.makeText(getApplicationContext(), "Invalid IP Address",
          Toast.LENGTH_LONG).show();
  }     
  
      try
      {
          BufferedReader reader = new BufferedReader
              (new InputStreamReader(is,"iso-8859-1"),8);
              StringBuilder sb = new StringBuilder();
              while ((line = reader.readLine()) != null)
      {
              sb.append(line + "\n");
          }
              is.close();
              result = sb.toString();
          Log.e("pass 2", "connection success ");
  }
      catch(Exception e)
      {
      Log.e("Fail 2", e.toString());
  }     
  
  try
      {
          JSONObject json_data = new JSONObject(result);
          name=(json_data.getString("name"));
      Toast.makeText(getBaseContext(), "Name : "+name,
          Toast.LENGTH_SHORT).show();
      }
      catch(Exception e)
      {
          Log.e("Fail 3", e.toString());
      }
  }
  </code></pre>
  
  <p>LogCat Error:</p>
  
  <pre><code>11-17 02:40:58.059: E/Fail 1(1073): android.os.NetworkOnMainThreadException
  11-17 02:40:58.079: E/Fail 2(1073): java.lang.NullPointerException: lock == null
  11-17 02:40:58.079: E/Fail 3(1073): java.lang.NullPointerException
  </code></pre>
  
  <p>any help appreciated... </p>