Tashen Jazbi
Tashen Jazbi

Reputation: 1068

how to fetch data from google app engine datastore in android

i'm new to google app engine and i follow it's documentation at https://developers.google.com/appengine/docs/ carefully.Now I've successfully stored my data on google app engine store by creating web application in eclipse for example i store first and last name of employee at GAE store like

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();


Entity employee = new Entity("Employee");

employee.setProperty("firstName", "Antonio");
employee.setProperty("lastName", "Salieri");

Date hireDate = new Date();
employee.setProperty("hireDate", hireDate);

employee.setProperty("attendedHrTraining", true);


datastore.put(employee);

and i've also deployed my project to GAE but now i want to get that stored data from data store in my android app. is this possible to do that. any help would me much appreciated.

Thanks!

Upvotes: 1

Views: 3213

Answers (2)

Pulak
Pulak

Reputation: 1

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Query q = new Query("Student");

        PreparedQuery pq = datastore.prepare(q);


        for (Entity entity : pq.asIterable()) 
{

        String nm=(String)entity.getProperty("Name");
        String em=(String)entity.getProperty("E-Mail");
    }
     resp.getWriter().println((String)entity.getProperty("Name"));

          resp.getWriter().println((String)entity.getProperty("E-Mail"));

Upvotes: 0

Lipis
Lipis

Reputation: 21835

There different approaches to this problem. Usually you would create some kind of services, most likely in JSON format and then you'll be able to interact from your Android app with Google App Engine using HTTP requests. Even better solution though would be to use the Google Cloud Endpoints:

Google Cloud Endpoints consists of tools, libraries and capabilities that allow you to generate Endpoints and client libraries from an App Engine backend to simplify client access to that web app. Endpoints makes it easier to create a web backend for web clients and mobile clients such as Android or Apple's iOS.

Upvotes: 2

Related Questions