Reputation: 11
I'm new for using Android Studio and java language.
I'm trying to get single text from windows azure mobileservices but I couldn't figure out that. for example I need to get 1 text from database(windows azure mobileservices) with out Id or any thing else to use it as String to use it in the application.
so could you please help me.
this code below for get mobileservices list from azure by using Android Studio.
private void refreshItemsFromTable() {
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final List<ToDoItem> results = refreshItemsFromMobileServiceTable();
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.clear();
for (ToDoItem item : results) {
mAdapter.add(item);
}
}
});
} catch (final Exception e) {
createAndShowDialogFromTask(e, "Error");
}
return null;
}
};
runAsyncTask(task);
}
private List<ToDoItem> refreshItemsFromMobileServiceTable() throws ExecutionException, InterruptedException {
return mToDoTable.where().field("complete").
eq(val(false)).execute().get();
}
I need code that help me to get string from windows azure mobileservices. please help me.
Upvotes: 1
Views: 107
Reputation: 24148
Please follow the code in the section How to: Return all Items from a Table
of the document "How to use the Android client library for Mobile Services".
Accroding to the source code MobileServiceList.java
, it extends the parent class ArrayList
, so you can get the element of the list via the method E get(int index)
, please see the code below.
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final MobileServiceList<ToDoItem> result = mToDoTable.execute().get();
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.clear();
mAdapter.add(result.get(0));
}
});
} catch (Exception exception) {
createAndShowDialog(exception, "Error");
}
return result;
}
}.execute();
Upvotes: 1