Rajath
Rajath

Reputation: 11926

Reusing code between Android and Google App Engine

I'm new to GAE, but have worked on Android for a while now. I'd like to write some code that basically parses xml files and stores it on a database at the backend. Then send part of this data based on a query to the front-end android app.

The android app in turn will store the data in the local database. Here, if possible, I would like to reuse code from the GAE and the Android app. So, my questions are:

Thanks,
Rajath

Upvotes: 0

Views: 81

Answers (1)

LJSilver
LJSilver

Reputation: 603

in GAE basically you have two non exclusive choiches: The Google Cloud SQL and the Datastore.
Which is better and which to use it depends on your application. The SQL server is a classical mySQL base database while the Datastore is based on a different non-relational structure and you should take some time to get familiar with it.

Generally speaking you can reuse code being in both cases Java, however there are many cases in which you interface with different services (ex. a local android sql service rather than the google datastore) therefore in this cases you have to adapt your classes. I can suggest in these cases to reuse concepts rather than code, let me explain: imagine you have to manage images. you take a picture in android and you have to associate to it some informations, for this purpose you can define a custom data model (let say a class AppImage). AppImage will contains only data and basic methods. Then you can for example create a class that manages AppImages (ImagesManager) (implementing upload, local storage and so on). In the serverside tyou will have a similar structure with that can differ for the persistency technologies. Therefore you can again create a similar object AppImage and also a class that manages them (ImagesManager). What will be different in the code will be the API calls to store info and in these cases you have no choiche and you have to write custom code, however the high level structure remains the same and this may help when things start getting complex.

The comment above worth also for the xml parsing problem. (What libraries are there for processing XML on Google App Engine/Java Servlet)

Upvotes: 1

Related Questions