简体   繁体   English

从Azure移动服务Android获取预加载的数据

[英]Get Preloaded Data from Azure Mobile Service Android

I want to get all the preloaded datas available on my Windows Azure Mobile Service. 我想在Windows Azure移动服务上获得所有可用的预加载数据。

Let's just say I have a Table named RV_RoadData and inside the Table, there is a Column for StudentIDs as Integer and Text as String. 假设我有一个名为RV_RoadData的表,并且该表中有一个学生ID列(作为整数)和文本(字符串)。 There are 50 Values loaded so far. 到目前为止,已加载50个值。

I just want to save those values in my ArrayList and then use for future references. 我只想将这些值保存在ArrayList中,然后用于将来的引用。 This is what I tried: 这是我尝试的:

public class MainActivity extends ActionBarActivity {

TextView textView;
Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    fechFromAzure();
}


//this is the only method talking to azure.
//here, no threads/asynctasks are used. So, fetching operation should    not take more
//than 5 seconds. Otherwise, app will freeze.
private void fechFromAzure(){
    try {
    //initialize the mobile service
    MobileServiceClient mClient = new MobileServiceClient(
            "https://******.azure-mobile.net/",
            "*******************************",
            this
    );

    //get the todo-item table
    MobileServiceTable<RV_RoadData> RV_RoadData_Table = mClient.getTable(RV_RoadData.class);

    //select all items from todo-item
    List<RV_RoadData> itemList = RV_RoadData_Table.where().execute().get();

    //set text of first and only one todo-item to textview
    textView.setText(itemList.get(0).Text);

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}

class RV_RoadData {
    public String Id;
    public String Text;
    }
}

But is seems to give me unwanted Exception. 但是似乎给了我不必要的异常。 I really don't know where I am doing wrong. 我真的不知道我在哪里做错了。 Please help to solve this problem. 请帮助解决此问题。 Thanks. 谢谢。

Try following the pattern in this tutorial, which uses an adapter to store a list of data. 尝试遵循本教程中的模式,该模式使用适配器来存储数据列表。

https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-data/ https://azure.microsoft.com/zh-CN/documentation/articles/mobile-services-android-get-started-data/

It also returns a MobileServicesList instead of a List. 它还返回MobileServicesList而不是List。 The data in its database is also very similar to yours, so it should be very easy to adapt it. 数据库中的数据也与您的数据库非常相似,因此应该很容易进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得预装在Android或iPhone中的移动应用程序? - How to get an mobile app preloaded in android or iphone? 获取移动服务客户端作为全局变量,并将数据从Android中的另一个类存储在Azure中 - Get mobile service client as a global variable and store the data in Azure from another class in Android 从Azure移动服务将数据检索到Java中的Android应用程序 - Retrieve data from a azure mobile service into a android apllication in java 如何从Azure移动服务检索数据并绑定到Android ListView - How to retrieve data from Azure Mobile Service and bind to Android ListView Windows Azure Service Mobile从表中获取所有数据 - Windows Azure Service Mobile get All data from table 从Azure移动服务将Blob下载到Android - Download blobs from azure mobile service to android 在Android中获取预加载的文件 - Get preloaded file in android 当我想从Android Studio中的预加载数据库中获取数据时出现应用程序错误 - Error in app when i want to get data from preloaded database in android studio 从Azure移动服务本地数据库访问错误,在单个Android类中访问两个不同的表数据 - Access Two Different Table Data in a Single Android Class, from Azure Mobile Service Local Database Getting Error 用于我的Android应用程序中的持久数据的Azure移动服务不起作用 - Azure Mobile service for persistent data from my Android app, does not work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM