Reputation: 9295
I would like to use NameValuePair
that is part of Apache commons-lang (link). The problem is I am getting an error when trying to initialize NameValuePair
object, like this:
NameValuePair pair = new NameValuePair()
or like this:
NameValuePair pair = new NameValuePair("name", "value")
.
Currently the only import that suggested for NameValuePair
is org.apache.http.NameValuePair
. So I downloaded commons-lang jar from the above link and added it to the libs folder in my project.
Still the only import option that is available is the one mentioned above.
Thanks for any help.
Upvotes: 1
Views: 889
Reputation: 257
NameValuePair is a public interface, an abstract class.
You should use BasicNameValuePair to initialize a name value pair.
for example,
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("timestamp", timestamp));
pairs.add(new BasicNameValuePair("key", value));
Upvotes: 2
Reputation: 16082
NameValuePair does not have the constructor. And this class is not included in Apache-commons jar.
Try to use BasicNameValuePair instead.
BasicNameValuePair pair = new BasicNameValuePair("name", "value");
Upvotes: 1