NameValuePair is deprecated in API 22

丶灬走出姿态 提交于 2019-12-01 17:15:30

You can use contentValues for example

ContentValues values=new ContentValues();
values.put("username",name);
values.put("password",password);

You can use httpmime.jar file instead of it, which will work better that NameValuePair. You can Download it from here, http://www.java2s.com/Code/JarDownload/httpmime/httpmime-4.3.jar.zip/

Here is the sample code to use 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 MultipartEntity class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!