How to Retrieve and use a single value from Azure mobile services in Android using Java

0 votes

I am new to Azure and following the Azure official documentation that talks about retrieving and storing data to Azure - 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?

Apr 1, 2019 in Azure by sabby
• 4,370 points
1,153 views

2 answers to this question.

0 votes

You don't need to create a custom API. 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();

Remember to create a class User for serialization and all. Also, define the array .

answered Apr 1, 2019 by Prerna
• 1,960 points
0 votes

You don't need to create a custom API. 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();

Remember to create a class User for serialization and all. Also, define the array .

answered Apr 1, 2019 by Prerna
• 1,960 points

Related Questions In Azure

0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 58,020 points
14,019 views
0 votes
1 answer

How to serialize and de-serialize a PFX certificate in Azure Key Vault?

Here's a PowerShell script for you. Replace ...READ MORE

answered Sep 24, 2018 in Azure by club_seesharp
• 3,450 points
1,772 views
0 votes
1 answer
0 votes
1 answer

How to import an image from Docker Hub to a private registry in Azure?

Hi@akhtar, You can import any image from Docker ...READ MORE

answered Nov 13, 2020 in Azure by MD
• 95,460 points
1,622 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,834 views
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,744 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,810 views
0 votes
1 answer

How to debug Azure 500 internal server error?

You can simply turn off custom error in ...READ MORE

answered Mar 29, 2019 in Azure by Prerna
• 1,960 points
4,868 views
0 votes
1 answer

How to check if multiple files exist in Azure container?

foreach loop is the most efficient way though. ...READ MORE

answered Mar 4, 2019 in Azure by Prerna
• 1,960 points
3,879 views
0 votes
1 answer

How to download a file from Blob Storage to the browser?

If you use ASP.NET (core), you can ...READ MORE

answered Mar 26, 2019 in Azure by Prerna
• 1,960 points
7,236 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP