简体   繁体   中英

How to use the Google App Engine as a backend database for Android applications

I'm actually a beginner in android and needs a lot of help. I have made an app with embedded database and now want to put it onto some dynamic location. Have simple form of data (some addresses and branch information etc). I actually have no idea about how to use a dynamic server placed on dynamic location.

How can I do this? Please guide me stepwise

I browsed and found some terms like " write Service ", " Close/open back-ends " etc. Kindly do guide me. Another question that I have is: do I need some kind of registration, api-key or any other thing. I just added the "google plugins" for eclipse and I can create App engine connected with Android App

Yes you do need a key. Look at this http://developer.android.com/google/gcm/gs.html

First, we need to send data to/from the client for the example you set up ( App engine connected with Android App ) using

com.google.android.gcm.server.Sender helper class

Again, that helper class is step #4 and how to use it is in Writing the Server-side Application Server-side Application

Naturally then you want to persist or look up data. You can do that in the whatever class is used to send/receive messages (which of course uses the Sender helper class above)

Then the easiest and maybe best way for AppEngine if you are using Java is to use Objectify. Trust me or google it to see how good it is. https://code.google.com/p/objectify-appengine/

The docs for Objectify are really good and I didn't really have any trouble the first times.

Their simple example is:

@Entity
class Car {
    @Id String vin; // Can be Long, long, or String
    String color;
}

ofy().save().entity(new Car("123123", "red")).now();
Car c = ofy().load().type(Car.class).id("123123").get();
ofy().delete().entity(c);

I think you are good to go.

Summary:

  • YourMessageClass (on Appengine)

    -- uses com.google.android.gcm.server.Sender to send/recieve data

    -- uses Objectify to persist data.

The next question is where are you putting YourMessageClass. Will it be in a Servlet that is handling a short-lived request? ( https://developers.google.com/appengine/docs/java/runtime#Requests_and_Servlets ) Will it be in a long-running backend? ( https://developers.google.com/appengine/docs/java/backends/ ) but that is beyond the scope of this discussion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM