I try to use this code to connect to server for uploading an image.
    try {
        url = new URL(requestURL);
        HttpURLConnection conn = (HttpURLCo         
        Hi am also facing the same problme.Now resolved using below code.I hope it will also help you.. try it....
Put this below code within onCreate()
 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_upload_documents);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
   //Statement or Controls Declaration or your code
}