Instead, you can use the httpmime.jar file, which will work better than NameValuePair. You can download it here, http://www.java2s.com/Code/JarDownload/httpmime/httpmime-4.3.jar.zip/
Here is sample code for using httpmime,
MultipartEntity multi = new MultipartEntity(); try { multi.addPart("name", new StringBody("Sahil")); multi.addPart("country", new StringBody("India")); } catch(Exception e){ System.out.println(""+e); }
just add this jar to your project, and then you can access the MultipartEntity class.
source share