Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameValuePair is deprecated in API 22

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);
    }

}
like image 859
Apsaliya Avatar asked Apr 07 '15 05:04

Apsaliya


2 Answers

You can use contentValues for example

ContentValues values=new ContentValues();
values.put("username",name);
values.put("password",password);
like image 89
Rahul M Mohan Avatar answered Oct 13 '22 19:10

Rahul M Mohan


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.

like image 20
Sahil Garg Avatar answered Oct 13 '22 20:10

Sahil Garg