问题描述
我一直在关注有关如何将数据从android应用程序插入数据库并使其正常工作的在线教程
I been following online tutorials on how to insert data into a database from an android app and have everything working except this small part
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
不推荐使用
NameValuePair和BasicNameValuePair,而推荐使用openConnection()
.我该如何创建一个新值关联? http://developer.android.com/reference/java/net/URL.html# openConnection()
NameValuePair and BasicNameValuePair have been deprecated in favor of openConnection()
. How can I create a new-value association with that? http://developer.android.com/reference/java/net/URL.html#openConnection()
有人知道我如何使用openConnection创建名称值对吗?我到处都在搜索.
Does anyone know how I can create name value pairs with openConnection? I been searching everywhere.
推荐答案
您可以使用ContentValues
,例如:
ContentValues values = new ContentValues();
values.put("username", name);
values.put("password", password);
database.insert(Table_name, null, values);
这篇关于对于OpenConnection不推荐使用NameValuePair的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!