Sync Android with a website database?

好久不见. 提交于 2019-12-04 08:22:36

问题


So this is what I need to do before my traineeship ends.

  1. connect android app with the database from a website
  2. store some information into the database
  3. retrieve some information back from the database

I have already experience with the standard sqlite build in android apps. The problem is, I need to let people get some information from the server so they can share information with the others. I have 3 weeks left before I'm done with my traineeship, so any help would be much appriciated.


回答1:


1) Create an SQLite database (Windows GUI SQLite prog: http://sqliteadmin.orbmu2k.de/)

2) Put it on a server

3) make a php script that will update / read your database (on the server)

 <?php

$row_id = $_GET['yourRowId'];
$submitted_var = $_GET['yourUpdateVar'];

if($database = new PDO("sqlite:your_sqlite_database.s3db")){

  //insert data into database
  $query = "UPDATE your_table SET some_field=$submitted_var WHERE _id=$row_id";

  $database->query($query);

  echo DONE;
 } else {
die($err);
 }
?>

4) Call this php script from your android app

 http://yourserver/yourfolder/yourscript?yourRowId=1&yourUpdateVar=3
 http://yourserver/yourfolder/yourReadScript (parse html response)

Done

That's how I'd do it in 3 weeks :-)

OOI were's ur traineeship @?



来源:https://stackoverflow.com/questions/6231633/sync-android-with-a-website-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!