您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Java-如何在Android中从Azure移动服务中检索和使用单个值

Java-如何在Android中从Azure移动服务中检索和使用单个值

解决了。无需创建自定义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();

忘记Userserialization所有人创建一个类。另外,您应该定义数组。

design[0] 是大小为1的数组。

eq(x)等于xwhere,x变量包含要从数据库(azure)指定的用户名

java 2022/1/1 18:35:58 有338人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶