Android应用程序从远程数据库获取数据 [英] Android application that gets data from a remote database

查看:142
本文介绍了Android应用程序从远程数据库获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写将使用发布/订阅模式,从将一些远程服务器上运行的数据库获取数据的Andr​​oid应用程序。这是一个原型应用程序,所以我只是要托管服务器我家的电脑上。我使用的Ubuntu。我已阅读和研究这个话题,但有散落的答案各种各样。我有很多的解决这一问题,但对于初学者..

I am attempting to write an Android application that will use the publisher/subscriber model to get data from a database that will be hosted on some remote server. This is a prototype application so I am just going to host the server on my home PC. I am using Ubuntu. I have read and researched this topic but there is a wide array of scattered answers. I have a lot of questions dealing with this but for starters..

  • 什么是承载包含数据库的服务器,与Android使用的最佳方法是什么?
  • 在做这件事我用的是什么类型的数据库?
  • 在我使用Android的SQLite API来从数据库中获取数据

我看在多个地方,它不是犹太从任何物品在网上直接连接到数据库,特别是来自移动设备。所以,我想我需要使用某种形式的HTTP,REST或东西的那种。

I read in multiple places that it is not kosher to connect to a database from anything over the internet directly, especially from a mobile device. So I think I need to use some sort of HTTP, REST or something of the sort.

我不精通任何这一点,所以如果有相关信息将AP preciated。

I am not well versed in any of this, so if any relevant information would be appreciated.

感谢

推荐答案

什么是承载包含一个数据库服务器的最佳方法是什么?

从服务器与数据库进行通信的观点出发,通常没有区别是否是机器人或任何其他客户端。最重要的是你定义(在你的情况下,Android的)服务器和客户机之间的通信以及协议。最好的可能是一些基于http协议(REST而定)。

From the standpoint of server communicating with database, normally there is no difference whether it is Android or any other client. What is important is that you define well protocol of communicating between server and client (Android in your case). The best probably would be some http based protocol (REST may be).

不要紧,我用的是什么类型的数据库?

有关客户端也没关系。 Android将只是另一个客户端。所以没关系你。选择一个最容易得到持续,并顺利通过了。 MySQL和Postgres的都不错的候选人。

For the client it does not matter. Android will be just another client. So it does not matter for you. Choose the one that is easiest to get going and well adopted. MySql, Postgres are good candidates.

我使用Android的SQLite API来从数据库中获取数据。

没有

我看了在多个地方,它不是犹太从任何直接上互联网

您肯定不希望这样做。更重要的是,当你设计你的服务器,你可能要分开code,讨论从code数据库中,讨论到客户端。这将是面向服务架构的基础。

You surely don't want to do it. More importantly, when you design your server you may want to separate code that talks to the database from code that talks to your client. That would be a basis of service oriented architecture.

这篇关于Android应用程序从远程数据库获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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