爪哇 - 如何获取并使用单个值从蔚蓝的Andr​​oid移动服务爪哇、蔚蓝、oid、Andr

2023-09-07 14:15:09 作者:没水的鱼一样能活

我是新来的蔚蓝,但我知道怎么样来检索和存储数据,以蔚蓝的,我也跟着为此,蔚蓝的官方文档某些事情。

I am new to azure but i know certain things like how to retrieve and store data to azure , i followed azure official documentation for this purpose.

Link是这里 - https://azure.microsoft.com/en-in/documentation/articles/mobile-services-android-get-started-data/

Link is Here - https://azure.microsoft.com/en-in/documentation/articles/mobile-services-android-get-started-data/

但问题是,这个教程只展示了如何检索和蔚蓝的使用适配器和列表使用数据。 我想知道,我怎么能检索蔚蓝的移动服务的单一价值,以及如何使用它在机器人

But the problem is, this tutorial is only showing How to retrieve and use Data from azure using Adapters and Lists . I want to know , How can i retrieve a single value from azure mobile services and how to use it in android.

Plzz我提供两个后端code(如果有的话)和Java code这一点。在此先感谢

Plzz provide me both backend code (if there is any) and java code for this . THANKS in advance

推荐答案

我把它解决了。无需创建一个定制的API。

I got it solved. No need to create a custom API.

只要遵循的基本知识,这里是code: -

Just follow the basics , Here is the code :-

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 forget to create a class User for serialization and all. Also you should define the array .

随便写如果你得到了它不能正常工作。

FEEL FREE to write if you got it not working.

编辑: -

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

EQ(X)等于 X 其中, X 变量包含用户名,我想从数据库(蔚蓝)称号。

eq(x) is equal to x where , x variable contains username for which i want designation from database (azure).