我一直在关注有关使用 java 低级 api 与应用引擎数据存储进行交互的应用引擎文档。我试图弄清楚我需要哪些导入和语法更改才能在 android 中进行这项工作。我在下面混合了android和java代码。java put() 和 get() 方法的正确 android 语法是什么?
package com.direction.investor.bcms;
//PSUEDO CODE
//JAVA IMPORTS. ANDROID EQUIVALENTS?
//import com.google.appengine.api.datastore.DatastoreService;
//import com.google.appengine.api.datastore.DatastoreServiceFactory;
//import com.google.appengine.api.datastore.Entity;
//import com.google.appengine.api.datastore.Key;
//import com.google.appengine.api.datastore.KeyFactory;
//import com.google.appengine.api.users.User;
//import com.google.appengine.api.users.UserService;
//import com.google.appengine.api.users.UserServiceFactory;
//import java.io.IOException;
//import java.util.Date;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Date;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
import android.widget.EditText;
public class ContactInfo {
public void onSubmitDataButtonPress{
//CONVERT INPUT TO STRING
EditText streetName;
streetName = (EditText) findViewById (R.id.streetNameEdit);
String streetInfo = streetName.getText().toString();
EditText zipCode;
zipCode = (EditText) findViewById (R.id.zipCodeEdit);
String zipInfo = zipCode.getText().toString();
}
// PLACE STRINGS ON DATASTORE
public class ContactInfoServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
Key ContactInfoKey = KeyFactory.createKey("Contact", contactkey);
String street = req.getParameter("streetInfo");
String zip = req.getParameter("zipInfo");
Date date = new Date();
Entity contacts = new Entity("UserContactInfo", contactkey);
contacts.setProperty("date", date);
contacts.setProperty("street", street);
greeting.setProperty("zip", zip);
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
datastore.put(contacts);
}
}
}