Hiya! I just finished a project using the same techniques. Perhaps I can be of some help?
First off, you should set up your domain with a database in mySQL and be able to address it with scripts written in php. For anyone with the most basic hosting plan, this is very easy to do. The basic tasks you want to perform on a database is SELECT (from your DB's records), INSERT (to create new records in the DB), and UPDATE (to change existing records). Detailed instruction on how to do this in php could be found all over the web, but I recommend looking at the php/ sql tutorials on w3schools: http://www.w3schools.com/php/php_mysql_intro.asp Let's say you have a mySQL table called "my_table" on your database set up with the following fields and records: ID ITEM_NAME VALUE 1 first_item "foo" Here's sample code on how to connect to your database, and set it up so you can return values from it using the GET method: <?php $con = mysql_connect(HOST NAME, USER NAME, PASSWORD); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(THE NAME OF MY DB, $con); $item_name = $_GET['item_name']; $queryDB = mysql_query("SELECT * FROM my_table WHERE item_name = \"" . $item_name . "\"); while($result = mysql_fetch_array($queryDB) { echo $result['value']; // this should return the word "foo" upon completion } mysql_close($con); ?> As for having Android talk to your website, the simplest way to do it is to use the GET method rather than using POST. That way, all you have to do is have Android go to a URL with the SQL query parameters as modifiers to the target URL. Here's a java example: public String getFromDB() { String recordIWantToQuery = "first_item"; String theBaseURL = "http:// mydomain .com/ my_php_script.php"; String theQuery = ""; String theResponse = ""; theQuery = theBaseURL + "?item_name=" + recordIWantToQuery; // will modify the query to "http:// mydomain. com/ my_php_script.php?item_name=first_item" try { URL url = new URL(theQuery); String line = null; InputStream is = (InputStream) url.getContent(); StringBuilder sb = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader (is)); while((line = reader.readLine()) != null) { sb.append(line + "\n"); } theResponse = sb.toString(); is.close(); } catch (MalformedURLException e) {} catch (IOException e) {} catch (NullPointerException e) {} return theResponse; } And response should contain the string "foo". You can also use the POST method (which is best if you want text blobs returned, or if you want to match a file you've uploaded to your server to a corresponding filename string, or whatever). That is formatted in another way, using another bag of tricks altogether, and there are some great code snippets out there. Try this post from anddev: http://www.anddev.org/viewtopic.php?p=1969 Best of luck! Harlo Holmes/Lovers v. Haters On Dec 4, 10:17 pm, hightechartist1 <[email protected]> wrote: > Hi, > > I'm new to develop an Android application to connect to a database on > my website. > > Which languages that would be the best to develop in database on my > live website for Android application? And what languages that I should > build a website that would be easy for Android app to POST data into > that website database? > > I need to know how to build Android app to connect database on my live > website but I don't want to have localhost database. Does anybody know > of a link to an example/tutorial or you could provide an exmaple in > which this kind of operation is performed? I would be happy to know > about it. > > Thanks! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

