安卓:连接到外部数据库连接到、数据库

2023-09-07 03:12:32 作者:爱你丶纯属意外

最近,我决定跟着我的一个老的梦想:创建一个在线的基于文本的RPG游戏。除了插图和图标它不会有任何图形。它将通过菜单和多项选择题的选项进行播放。结果我有几年的PHP和从浏览器的游戏体验MySQL的,但没有在Java和Android战线。这就是我挑的Andr​​oid的游戏......在这个过程中学习新东西的原因之一。

I recently decided to follow an old dream of mine: to create an online text-based RPG. Apart from illustrations and icons it won't have any graphics. It will be played through menus and multiple choice options. I have a few years of PHP and mySQL experience from a browser game but none in the java and android fronts. That's one of the reasons i picked android for the game... to learn new stuff in the process.

在我的问题:什么是最有效的(在性能和安全方面)的方式来一个Android应用程序连接到外部服务器托管的数据库?我一直在寻找这最后几天,至今我倾向于通过构建在PHP Web服务连接,然后返回在JSON结果,但我听说这是一个缓慢的方法。结果这是可能的做法非常沉重的数据库使用,而不会造成大量的滞后?几乎每一个玩家的行动将需要存储或正从数据库的东西。

On to my question: What's the most effective (in terms of performance and security) way to connect an android app to a database hosted in an external server? I've been looking at this the last few days and so far i'm leaning towards connecting it by building a web service in PHP and then returning the results in JSON but i heard it's a slow method. Is this approach possible with very heavy database usage without causing a lot of lag? Almost every player action will require storing or getting something from the Database.

感谢您的帮助!

推荐答案

是的,你将需要实现某种类型的API。你不想让你的应用程序直接连接到远程数据库并运行查询。

Yes you will need to implement an API of some kind. You don't want to allow your apps to connect directly to a remote database and run queries.