Wednesday, March 16, 2011

Re: [android-developers] mySQL android php

I have several apps which talk to mysql databases that I have on my websites. For me, I use a http post and json to talk between the two. For example, say I want a user to be able to insert some arbitrary data into a database (assuming he's already set up a username and password on my website). Here's the logical steps I take:

(Android app): Collect data, get saved login information
(Android app): Post data to my server
(Webserver): Gather the data  (in $_POST['username'], $_POST['password'], and $_POST['data']) and insert it however you need to.
(Webserver): Return success or failure through a JSON object (e.g. echo(json_encode(array('status'=>'ok', 'error_message' => ''))))
(Android app): Parse the JSON object, and look for either an "ok" status or and "error" status.

Anyway, I've been successful using that method, and I have two apps which currently use it.

Nick

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment