我是 azure 的新手,但我知道某些事情,例如如何检索数据并将数据存储到 azure,为此我遵循了 azure 官方文档。
链接在这里 -https://azure.microsoft.com/en-in/documentation/articles/mobile-services-android-get-started-data/
但问题是,本教程仅展示如何使用适配器和列表从 azure 检索和使用数据。我想知道,如何从 azure 移动服务检索单个值以及如何在 android 中使用它.
请为我提供后端代码(如果有的话)和java代码。提前致谢
我解决了。无需创建自定义 API。
只需遵循基础知识即可,这是代码:-
final String[] design = new String[1];
private MobileServiceTable<User> mUser;
mUser = mClient.getTable(User.class);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final MobileServiceList<User> result =
mUser.where().field("name").eq(x).execute().get();
for (User item : result) {
// Log.i(TAG, "Read object with ID " + item.id);
desig[0] = item.getDesignation(); //getDesignation() is a function in User class ie- they are getters and setters
Log.v("FINALLY DESIGNATION IS", desig[0]);
}
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
designation.setText(desig[0]);
}
}.execute();
DON'T忘记创建一个类User
for serialization
和所有。您还应该定义数组。
随意写如果你发现它不起作用。
EDIT :-
design[0]
是一个大小为 1 的数组。
eq(x)
等于x
在哪里 ,x
变量包含我想要从数据库(天蓝色)指定的用户名。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)