How to get data from an Azure DB table into an Android app?

I'm new to azure, I don't know how to connect to the table that I created in the Azure database. I want to get table data (SELECT *) and populate it in a GridView in android. I know the “filling” part with the adapter, all I want to know is how to connect and receive data from the table :)

I tried the IT tutorial from Microsoft, but I have some difficulties applying the same tutorial to my scenario.

Here is what I tried:

@Override

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);



setContentView(R.layout.activity_home_screen);

    try {
        mClient = new MobileServiceClient(
                "LINK",
                "KEY",
                this);

} catch (MalformedURLException e) {

}

    refreshItemsFromTable();
 }



private void refreshItemsFromTable()
{
          //ActivityData is my Entity class 

        new AsyncTask<Void, Void, Void>() {
            //
            @Override
            protected Void doInBackground(Void... params) {
                try {
                    //This is the problematic area. My actual table name is "Activity" on the Azure SQL
                    final MobileServiceList<ActivityData> result = mToDoTable.eq(false).execute().get();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            mAdapter.clear();

                            for (ActivityData item : result) {
                                mAdapter.add(item);
                            }
                        }
                    });
                } catch (Exception exception) {
                    Toast.makeText(HomeScreen.this, exception.toString(),Toast.LENGTH_LONG);
                }
                return null;
            }
        }.execute();
    }

How to specify SQL SELECT query in this script? Seems like this code is not a way to do this? I would like to populate the GridView with tabular data :)

+4
1

Azure Table Storage Android- REST API. , .

, () :

Request Syntax:
GET /myaccount/Customers()?$filter=(Rating%20ge%203)%20and%20(Rating%20le%206)&$select=PartitionKey,RowKey,Address,CustomerSince  HTTP/1.1

Request Headers:
x-ms-version: 2013-08-15
x-ms-date: Mon, 25 Nov 2013 15:25:14 GMT
Authorization: SharedKeyLite myaccount:<some key>
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8
DataServiceVersion: 2.0;NetFx
MaxDataServiceVersion: 2.0;NetFx

:

, Azure SQL. Azure ( no-sql).

0

All Articles