NameValuePair deprecated for openConnection
I just ran into the same problem. The deprecated classes from org.apache.http
have been removed in API 23
.
I ended up using android.util.Pair
. It works perfectly, and the code is shorter too:
List<Pair<String, String>> params = new ArrayList<>();params.add(new Pair<>("username", username));params.add(new Pair<>("password", password));
You can use ContentValues
, for example:
ContentValues values = new ContentValues();values.put("username", name);values.put("password", password);database.insert(Table_name, null, values);
Alternate to NameValuePair. Also you can get the name and values from it as mentioned below. Here key isa name.
Create:
ContentValues values = new ContentValues();values.put("key1", "value1");values.put("key2", "value2");
Get key and value :
for (Map.Entry<String, Object> entry : values.valueSet()) { String key = entry.getKey(); // name String value = entry.getValue().toString(); // value}