NameValuePair deprecated in API 22

Now that namevaluepair is deprecated in API 22. What should I do if I want to implement the namevaluepair interface. below is my code

package com.example.passpass; import org.apache.http.NameValuePair; public class DoubleNameValuePair implements NameValuePair{ String name; double value; public DoubleNameValuePair(String name, double value) { this.name = name; this.value = value; } @Override public String getName() { return name; } @Override public String getValue() { return Double.toString(value); } } 
+6
source share
2 answers

You can use contentValues ​​like

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

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.

+1
source

Source: https://habr.com/ru/post/984768/


All Articles