【问题标题】:Can I place string file from res/values/string.xml to remote host server and read it from there我可以将字符串文件从 res/values/string.xml 放置到远程主机服务器并从那里读取吗
【发布时间】:2013-12-14 19:49:16
【问题描述】:

我想将 string.xml 从我的 Android 应用程序 res/values/ 文件夹移动到我的网站。

http://example.com/string.xml

我从那里编辑它会比总是将应用程序更新到 google play 更容易。

这可能吗?

<?xml version="1.0" encoding="utf-8"?>
<resources>

 <string name="app_name">MyRadio</string>
    <string name="version">1.0</string>  


<string-array name="station_names">
        <item>NRG radio</item>              

<string-array name="station_urls">
        <item>rtmp://radiostation.com/radiomp3</item>

<string-array name="station_detail">
        <item>Radio detail</item>

【问题讨论】:

    标签: java android xml eclipse string


    【解决方案1】:

    当然欢迎您在您的 Web 服务器上托管文件。当然欢迎您在您的应用程序中自己将这些文件下载到用户的设备上。然而:

    • 您需要下载文件
    • 您需要知道何时下载文件,具体取决于文件何时可能更改
    • 您需要解析文件,因为它们不再是字符串资源
    • 您需要调整代码以使用解析结果,而不是您当前使用的字符串资源

    【讨论】:

    • 感谢您的快速回答。我是 android 和 eclipse 的新手,所以我觉得这些事情对我来说很难做到。顺便说一句,你有一些关于这些东西的视频教程吗?我应该在 youtube 上搜索什么“解析”
    • 通常,strings.xml 存储不会经常修改的内容,例如标签、消息等。根据您的问题,我认为您需要的是 web 服务 (en.wikipedia.org/wiki/Web_service)。考虑一下您的应用程序在服务方面的需求,例如“我需要附近的餐馆列表”或“给我的用户从 7 月开始的消耗品”。正如@CommonsWare 在他的回答中指出的那样,您将解析您的“字符串”(服务的答案)。希望您可以遵循一些方法,例如 JSON vogella.com/articles/AndroidJSON/article.html
    • Bolhoso 谢谢。在我的字符串中,我有一些经常可以更改广播电台的网址。如果需要删除或添加新站,在我的服务器上编辑 xml 比将洞应用程序更新到谷歌更容易,对不起我的英语。我希望我能以某种方式解释。
    猜你喜欢
    • 1970-01-01
    • 2022-11-24
    • 2023-03-05
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    • 2021-12-18
    相关资源
    最近更新 更多