If you are running on 3.0, i can't help; Because Strict mode is on by default in it; But its above tat, then this might help
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Include this before your HTTP connection creation; Then it works