我一直在关注有关如何将数据从 android 应用程序插入到数据库中的在线教程,并且除了这个小部分之外,一切正常
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
NameValuePair 和 BasicNameValuePair 已被弃用,取而代之的是 openConnection()
。我怎样才能创建一个新的值(value)关联呢? http://developer.android.com/reference/java/net/URL.html#openConnection()
有谁知道我如何使用 openConnection 创建名称值对?我到处找。
最佳答案
我刚刚遇到了同样的问题。 org.apache.http
中已弃用的类已在 API 23
中删除。
我最终使用了 android.util.Pair
。它运行良好,代码也更短:
List<Pair<String, String>> params = new ArrayList<>();
params.add(new Pair<>("username", username));
params.add(new Pair<>("password", password));
关于java - 不推荐使用 OpenConnection 的 NameValuePair,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29378012/