如何从android手机服务器的数据库进行通信? [英] How to communicate with server's database from android phone?

查看:97
本文介绍了如何从android手机服务器的数据库进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在做一个应用程序,它会与将要在服务器上托管一个简单的数据库进行通信。该数据库将只有三列,一_id,标题和URL链接。我已经使用SQLiteDatabase使用手机的本地数据库成功地做到了这一点,但我想它使任何其它手机也能访问同一个数据库。我会在电脑上更新服务器的数据库(添加新行),这样的手机应该反映这些变化。

I'm currently making an app where it would communicate with a simple database that will be hosted on a server. The database will only have three columns, a _id, title, and url link. I've successfully done this using the phone's local database using SQLiteDatabase but I want it so that any other phone can also access the same database. I will be updating the server's database (adding new rows) on the computer so the phones should reflect these changes.

我相信我会在服务器上使用的SQLite太创建数据库。基本上,我希望所有的改变将处理来自手机做它像我是如何与本地数据库在服务器端,而不是。在电话应能够访问数据,并相应地使用它。任何人都可以解释我没有办法做到这一点?

I believe I will be using sqlite on the server too to create the database. Basically I want all changes to be handle on the server side instead of doing it from the phone like how I am with the local database. The phone should be able to access the data and use it accordingly. Can anyone explain me a way to do this?

感谢你在前进!

推荐答案

您将需要通过Web界面,露出数据库。一个好的办法就是使用 RESTful Web服务。你可以每行重新present作为一个对象,并使用HTTP GET请求来获取它,一个HTTP POST进行更新和HTTP PUT或者HTTP POST插入新的条目。当然,你需要使用网络技术和某种类型的应用程序服务器。

You will need to expose the database through a Web interface. A good way will be to use a RESTful web service. You could represent each row as an object and use an HTTP GET request to retrieve it, an HTTP POST to update it and an HTTP PUT or HTTP POST to insert new entries. Of course you need to use a web technology and an application server of some kind.

这篇关于如何从android手机服务器的数据库进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆