Now that namevaluepair is deprecated in API 22. What can i do if i want to implement '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);
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With