Java Low Level API app engine Android equivalent

243 views Asked by At

I've been following the app engine documentation on using the java low level api to interact with an app engine datastore. I'm trying to figure out what imports and syntax change I need to make this work in android. I have below mixed between android and java code. What is the proper android syntax for the java put() and get() methods?

 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);

    }
}



}
1

There are 1 answers

0
dragonx On BEST ANSWER

I don't think you understand the App Engine architecture. The low level API runs on App Engine instances. You cannot use it on android. Period.

If you want your android app to interact with App Engine, it has to be via an HTTP interface. You can either write your own handlers on App Engine, or with much less code, use App Engine Endpoints, which essentially generate HTTP request handlers to interact with your models.