title: Android Java Null Pointer Exception
body: <p>I am trying to connect to a database on a remote server.<br>
  I have the following code with private details masked: <br></p>
  
  <pre><code>
  public static void connectToServer () {
          Log.e(tag,"Inside connectToServer");
          String result = "";
          ArrayList toDB = new ArrayList();
  
          //Assign namevalue pairs to toDB
          try {
              toDB.add(new BasicNameValuePair("A",dta.getA()));
              toDB.add(new BasicNameValuePair("B",dta.getB()));
              toDB.add(new BasicNameValuePair("C",dta.getC()));
              toDB.add(new BasicNameValuePair("D",dta.getD()));
              toDB.add(new BasicNameValuePair("E",dta.getE()));
              toDB.add(new BasicNameValuePair("F",dta.getF()));
          } catch (Exception e) {
              Log.e(tag,e.toString());
          }
  
          //http post
          try{
                  HttpClient httpclient = new DefaultHttpClient();
                  HttpPost httppost = new HttpPost("http://mydom.com/myFolder/file.php");
                  httppost.setEntity(new UrlEncodedFormEntity(toDB));
          }catch(Exception e){
                  Log.e(tag, "Error in http connection "+e.toString());
          }
      }
  </code></pre>
  
  <p>My manifest file is as follows:
  <code><br>
  &lt; uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><br>
  &lt; uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><br>
  &lt; uses-permission android:name="android.permission.INTERNET" /><br>
  </code></p>
  
  <p>In logcat I have the following :
  <code><br>
  Inside connectToServer <br>
  java.lang.NullPointerException
  </code><br>
  <b> Why am I getting a NullPointerException ? </b><br>Thank you.</p>