不推荐使用NameValuePair [英] NameValuePair deprecated

查看:166
本文介绍了不推荐使用NameValuePair的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为不推荐使用Android 22 NameValuePair.

since Android 22 NameValuePair is deprecated.

文档使我读到有关openConnection的文章,但这就是我所做的.那么如何正确更换呢?

The documentation sends me to an article about openConnection, but that is what I do. So how is it replaced properly?

我知道我仍然可以使用它,并且必须构建一个字符串,只是弄清楚如何在方法之间传递数据.

I know I can still use it and a string has to be build, just figuring how to pass data between methods.

推荐答案

您可以使用ContentValues代替NameValuePair列表.

You can use ContentValues instead of list of NameValuePair.

创建:

ContentValues values = new ContentValues();
values.put("key1", "value1");
values.put("key2", 123);

用法:

for (Map.Entry<String, Object> entry : values.valueSet()) {
    String key = entry.getKey();
    String value = entry.getValue().toString();
}

这篇关于不推荐使用NameValuePair的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆