将Android与网站数据库同步? [英] Sync Android with a website database?
问题描述
- 将android应用程式与网站上的资料库连结
- 将一些信息存储到数据库
- 从数据库中检索一些信息
我已经在Android应用程序中使用标准的sqlite构建体验。
问题是,我需要让人们从服务器获取一些信息,所以
他们可以与其他人共享信息。
1)创建SQLite数据库(Windows GUI SQLite prog: http://sqliteadmin.orbmu2k.de/ )
2)将它放在服务器上
3)创建一个可以更新/读取数据库的php脚本(在服务器上)
<?php
$ row_id = $ _GET ['yourRowId' ];
$ submitted_var = $ _GET ['yourUpdateVar'];
if($ database = new PDO(sqlite:your_sqlite_database.s3db)){
//将数据插入数据库
$ query =UPDATE your_table SET some_field = $ submitted_var WHERE _id = $ row_id;
$ database-> query($ query);
echo DONE;
} else {
die($ err);
}
?>
4)从Android应用程序调用此php脚本
http:// yourserver / yourfolder / yourscript?yourRowId = 1& yourUpdateVar = 3
http:// yourserver / yourfolder / yourReadScript(parse html response)
完成
在3周内: - )
OOI是您的实习生@?
So this is what I need to do before my traineeship ends.
- connect android app with the database from a website
- store some information into the database
- 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) 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 @?
这篇关于将Android与网站数据库同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!