[英]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 我是Google App Engine的新手, 请仔细阅读https://developers.google.com/appengine/docs/上的说明文件。现在,通过在eclipse中创建Web应用程序,我已成功将数据存储在Google App Engine商店中例如我在GAE商店中存储员工的名字和姓氏,例如
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. 而且我也已经将项目部署到GAE,但现在我想从Android应用程序中的数据存储中获取存储的数据。 is this possible to do that.
这有可能做到吗 any help would me much appreciated.
任何帮助我将不胜感激。
Thanks! 谢谢!
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.
通常,您会创建某种服务,最有可能采用JSON格式,然后就可以使用HTTP请求从Android应用程序与Google App Engine进行交互。 Even better solution though would be to use the Google Cloud Endpoints :
更好的解决方案是使用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.
Google Cloud Endpoints包含工具,库和功能,可让您从App Engine后端生成Endpoints和客户端库,以简化客户端对该Web应用程序的访问。 Endpoints makes it easier to create a web backend for web clients and mobile clients such as Android or Apple's iOS.
端点使为Web客户端和移动客户端(例如Android或Apple的iOS)创建Web后端变得更加容易。
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"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.