简体   繁体   English

电晕; 如何创建数据库,以便用户可以使用其Android手机在线访问它?

[英]Corona; How do I create a database so that users can access it online using their android phones?

I am trying to make an game using corona sdk where a user can see what items he has and how much he has left. 我正在尝试使用电晕SDK制作游戏,让用户可以看到他拥有哪些物品以及还剩下多少物品。 Its abit like a inventory management app. 有点像库存管理应用程序。 How do i go about doing this? 我该怎么做? I have no idea what to do and where to start. 我不知道该怎么做,从哪里开始。 Currently what I found online is this: 目前,我在网上找到的是:

-- open "data.db". If the file doesn't exist, it will be created
local path = system.pathForFile( "data.db", system.DocumentsDirectory )
local db = sqlite3.open( path )

This actually creates a local database which I don't want. 这实际上创建了我不想要的本地数据库。 I'm guessing instead of "system.DocumentsDirectory" I should put in something else? 我猜应该代替其他“ system.DocumentsDirectory”? I referred online at corona labs ( http://coronalabs.com/blog/2012/04/03/tutorial-database-access-in-corona/ ) but nothing really gave me what I needed. 我在电晕实验室( http://coronalabs.com/blog/2012/04/03/tutorial-database-access-in-corona/ )上进行了网上转介,但没有什么能真正满足我的需求。

Any help on this is welcomed. 欢迎对此提供任何帮助。 Thanks. 谢谢。

EDIT: I'm using SQLite if that's important. 编辑:如果这很重要,我正在使用SQLite。 Also if anyone is not sure what I'm trying to ask, basically I'm trying to have a database stored online so that i can access it using my android device. 另外,如果有人不确定我要问的是什么,基本上我正在尝试将数据库在线存储,以便我可以使用Android设备访问它。 How do i do that and what tools do I need? 我该怎么办?我需要什么工具?

You would have to make a REST API to manage online database and then use the HTTP requests to create, remove, update or delete records. 您将必须制作一个REST API来管理在线数据库,然后使用HTTP请求来创建,删除,更新或删除记录。
I would suggest to work on HTTP server which would provide you endpoints to interact with your database records then use Corona's network requests to communicate with the server. 我建议在HTTP服务器上工作,该服务器将为您提供端点与数据库记录进行交互,然后使用Corona的网络请求与服务器进行通信。 You can use the JSON format to easily exchange data over HTTP. 您可以使用JSON格式轻松通过HTTP交换数据。

You can read more about network requests here . 您可以在此处阅读有关网络请求的更多信息。 If you want to know about REST APIs or database endpoints you can start reading about it here . 如果您想了解REST API或数据库端点,则可以在这里开始阅读。 You can read about using JSON in Corona SDK here . 您可以在此处阅读有关在Corona SDK中使用JSON的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM