title: How can I send from the server-side (Google App Engine, Cloud Endpoints) the information to my client?
body: <p>I have an Android Application that is stored in the Cloud, with Google App Engine. I use Cloud Endpoints. My problem is that I cannot send the data from the server to my client(Android Device), or better said, so far, I have no idea how to do that.</p>
  
  <p>So far, I have managed to insert data in the datastore, by creating an endpoint and calling the method that is in charge with adding a record in the database(that's located on the server side, in myProject - AppEngine) , using the following code (on the client):\</p>
  
  <pre><code> Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
   AndroidHttp.newCompatibleTransport(),
   new JacksonFactory(),
   new HttpRequestInitializer() {
   public void initialize(HttpRequest httpRequest) { }
   });
    Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
    endpointBuilder).build();
    try {
        // Construct the note.
        Note note = new Note().setDescription("Note DescriptionRoxana");
        String noteID = new Date().toString();
        note.setId(noteID);
  
        note.setEmailAddress("E-Mail AddressRoxana");        
        // Insert the Note, by calling a method that's on the server side - insertNote();
        Note result = endpoint.insertNote(note).execute();
    } catch (IOException e) {
      e.printStackTrace();
    }
  </code></pre>
  
  <p>But I cannot see a way of retrieving data from the datastore and to display it on the server side. I tried to do the same, create an endpoint, that will call the method that retrieves all the records in the database (method that is located on the server), but my application crashes.</p>
  
  <p>The code for the method that retrieves data from the datastore is the following:</p>
  
  <pre><code>    public CollectionResponse&lt;Note&gt; listNote(
          @Nullable @Named("cursor") String cursorString,
          @Nullable @Named("limit") Integer limit) {
  
      EntityManager mgr = null;
      Cursor cursor = null;
      List&lt;Note&gt; execute = null;
  
      try {
          mgr = getEntityManager();
          Query query = mgr.createQuery("select from Note as Note");
          if (cursorString != null &amp;&amp; cursorString != "") {
              cursor = Cursor.fromWebSafeString(cursorString);
              query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
          }
  
          if (limit != null) {
              query.setFirstResult(0);
              query.setMaxResults(limit);
          }
  
          execute = (List&lt;Note&gt;) query.getResultList();
          cursor = JPACursorHelper.getCursor(execute);
          if (cursor != null)
              cursorString = cursor.toWebSafeString();
  
          // Tight loop for fetching all entities from datastore and accomodate
          // for lazy fetch.
          for (Note obj : execute)
              ;
      } finally {
          mgr.close();
      }
  
      return CollectionResponse.&lt;Note&gt; builder().setItems(execute)
              .setNextPageToken(cursorString).build();
  }
  </code></pre>
  
  <p>You see, the returned type is collection response. You have access to this type of data, after performing the following import: </p>
  
  <pre><code>   import com.google.api.server.spi.response.CollectionResponse;
  </code></pre>
  
  <p>I inferred that this is a data type characteristic to the server side, thus, I have no idea how I can cast it into a List, ArrayList, or any other type of collection, that can be used on the client side.</p>
  
  <p>How should I do it then? Since adding data was so easy and so straight forward, I have assumed that retrieving data would be performed in the same manner, but apparently I am missing something essential for this matter.</p>
  
  <p>Thank you in advance!</p>