How to Fetch data

Home - How to Fetch data

Adam Puspabhuana asked 8 months ago

Hi,
I am newby in mesosfer, my problem right now is I still confuse in fetching data from query.
For example:
I have a bucket consists of 2 rows of data. If I read your tutorials, It is mentioned about FindAsync which is related with method using List View.
Question is:
a. How if I want to show all the data into gird view or text View?
b. How if I just want to get  one field of data?
c. Is there any tutorials how getAsync works?
 
Thank you.

1 Answers
Alann Maulana Staff answered 8 months ago

Hi Adam,
Let’s say that we have a bucket with json formatted data like this :

{
 "name":"John Doe",
 "age":20,
 "height":182.5,
 "address":{
  "street":"A. Yani",
  "number":5,
  "city":"Surabaya"
 }
}

So, if we want to get a each of bucket object for :

For a complete reference when using MesosferData class, please refer to Android API Reference. Ok, we’ve done for question A and B.
The last question C, what do you mean for getAsync? If you mean fetchAsync, you can refer to this sample Android app about how to fetch single MesosferData from Mesosfer Cloud. Here is some code about how to fetch data :

MesosferData.createWithObjectId("objectId").fetchAsync(new GetCallback<MesosferData>() {
   @Override
   public void done(MesosferData data, MesosferException e) {
     if (e != null) {
         // there is an exception happen, show error message
         return;
     }
     // data successfully fetched
   }
});

We hope this will answer all of your question.

 

Best regards

 

Your Answer