views:

525

answers:

5

I would like to write a client application for Android that uses the Google App Engine as a database backend. My Android client would connect to the App Engine to save information, then it would connect later for reports. Is it possible to use the App Engine as a backend like this?

+5  A: 

Yes, it is possible.

Laurence Gonsalves
How? I've been looking all over the documentation but can't seem to find APIs for Java that would allow a client application to directly connect to the GAE database. Can you point me to a link that explains the API?
Doughy
+1 for brevity.....
jhs
There's no API - you'll have to HTTP POST and GET to pass data back and forth by hand. I'm doing that with one app and it's working fine, but it's a bit more work than just connecting to an API.
Richard Watson
+1  A: 

Yes, it is very possible. You would not connect directly to the GAE database though. A better architecture would be to make your app hit a URL that writes to the DB. For example, you could set up a Struts 2 action that takes the values of your query parameters and then mutates and validates them as necessary before persisting them.

Ben McCann
+3  A: 

If you're looking for something like the remote api that the App Engine has in python, then you'll be disappointed to find it missing in Java.

That said, absolutely nothing stops your from hitting your app and posting data either through POST / JSON / XML / any other format you can think of. The same thing goes for getting your reports back.

If security is a concern, the OAuth protocol allows you to authenticate to app engine from your android device.

This is an aside, but as far as reporting is concerned, you might not find the app engine a very suitable platform for reporting type apps. Just make sure you understand its limitations - the lack of joins, 1000 object limit, no sum / average, necessary indexes, etc. It's certainly not impossible, but do think carefully about how you're going to model your data.

Sudhir Jonathan
+1  A: 

No.

In your response to Laurence, you said you want a direct DB connetion. A client cannot connect directly to the GAE datastore. You must write web handlers to interface between the client and your data. It doesn't have to be much, but it must be something.

jhs
+1  A: 

Yes, its very much possible. It's something I am also currently working on.

My code uses HTTP GET and HTTP POST and I am using a RESTful service on the GAE.

I'm sorry I can't provide any code because I am still learning however the library I'm using is called RESTLET. They have libraries for both GAE and Android however I'm only using RESTLET on the GAE and I'm just using the HTTP library in the Android SDK for the client.

http://www.restlet.org/

The version you require is 2.0 M6 and not the stable release.

Tom