获取变化很大的远程数据的最佳方法
有 3 个以上的应用程序以一个字符串的形式收集参数,例如“Peter”、“Jane”、“Mary”等。目前我将这些参数保存在 String[]
数组中。然而,数据需要改变很多,所以每隔几天我就必须修改字符串,重新编译 APK 并发布它。只是时间的腰部。
将这些数据保存在远程文件(而不是数据库)(可能是文本文件)中的最简单方法应该是什么,以便应用程序可以根据需要下载参数列表?我的想法是只更改此文件一次,将其上传到某个远程服务器,然后应用程序自动下载参数。这样我就不必重新编译和重新发布 APK。
如果文本文件是最简单的解决方案,那么它的形式应该是什么?例如我应该这样写参数
彼得、简、玛丽......
或者以其他形式?
在这个文本文件和 Android 应用程序之间是否需要一些层,就像我们在远程服务器上创建层以从数据库中获取数据一样?或者我可以直接从这个远程文本文件中获取数据?!
There are 3+ apps which collect parameters in the form of one string, like "Peter", "Jane", "Mary", etc. At the moment I keep this parameters in String[]
array. However, the data needs to be changed a lot so every few days I have to amend strings, recompile APKs and publish it. Just waist of time.
What should be the simplest way to keep this data in a remote file (NOT database), maybe text file, so that the apps can download list of parameters on need? My idea is to change this file just once, upload it to some remote server and then the apps download parameters automatically. This way I would not have to recompile and republish the APKs.
If the text file is the simplest solution, what should be the form of it? For example, should I write parameters like this
Peter, Jane, Mary, ...
Or in some other form?
Is there a need for some layer between this text file and Android app, like when we make layer on the remote server to grab data from database? Or I can simply grab data directly from this remote text file?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么,交付机制可以是您的应用程序对您控制的 Web 服务器执行的简单 HTTP GET。它可以像 http://myhost/names.txt 一样简单。
数据格式取决于您想要执行的操作。超级简单的解决方案是一个文本文件,每行具有不同的名称:
或者,您可以从服务器提供 JSON 并在客户端上解析它。
如果您希望将来添加更多值,JSON 解决方案将更具可扩展性,例如:
实际上完全取决于您对什么感到满意以及您的情况需要什么。
Well the delivery mechanism could be a simple HTTP GET your app performs to a web server you control. It could be as simple as http://myhost/names.txt.
The data format depends on what you want to do. The super simple solution would be a text file with a different name on each line:
Or, you could serve up JSON from the server and parse it on your client.
The JSON solution would be more extendable, should you wish to add more values in future, e.g.:
Really depends entirely on what you're comfortable with and what your situation calls for.