0

From the documentation here, we can see that it is org.apache.http.NameValuePair, so looking at the original documentation given here at apache.org, it has the constructor:

public NameValuePair(String name,
                     String value)

But I also want to store other data type values, like boolean and int. How can I do that?

Solace
  • 8,612
  • 22
  • 95
  • 183
  • Use a `Map` of some sort instead. http://developer.android.com/reference/java/util/Map.html – Simon Nov 26 '14 at 19:17
  • That's where I started, but map can store values of one data type right? I have like 10 keys with values, where keys are Strings and values are Strings, booleans, or ints. Now shall I make 10 maps each having one key-value pair, because a single map won't allow me to store values of different datatypes; so I thought about saving them in some *generic* sort of `NameValuePair` and then make an array of those `NameValuePair`. @Simon – Solace Nov 27 '14 at 02:09

1 Answers1

0

NameValuePair and other deprecated classes from org.apache.http have been removed entirely in API level 23.

You can use android.util.Pair, which uses generics and lets you store any data type, e.g.:

// stores boolean values    
Pair<String, Boolean>> p1 = new Pair<>("key", false));

// stores int values
Pair<String, Integer>> p2 = new Pair<>("key", 1));
friederbluemle
  • 33,549
  • 14
  • 108
  • 109