将值动态写入存储在 asset 文件夹内的 html 文件
我的资产文件夹中存储了一个 html 文件,例如 /assets/something.html。现在我想动态地为其写入一个来自我的网络服务的值。我已将我的值存储到某个变量中,现在我希望将该值写入 Something.html 文件中。
有什么方法可以做到这一点吗?当我上网搜索时,我得到一些答案说这是不可能的,这是正确的吗?
I have a html file stored in my assets folder say /assets/something.html. Now I want to write a value for it dynamically which comes from my web service. I have stored my value into some variable and now I want this value to be written into something.html file.
Any ways to do this? When I surfed for this, I got some answers saying it is not possible, is it correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
资产通常是静态的,换句话说,您不会更改它们。它们仅供您在您的应用程序中使用。如果您需要在用户手机上持久存储数据(例如从网络服务获取的值),请查看 Android 数据存储
Assets are generally static, in other words you don't change them. They're there for you to use in your app only. If you need to store data persistently on the users phone (like the value you get from your web service), please take a look at the documentation for Android Data Storage
我通过读取assets文件夹中的html文件并将它们放入字符串中解决了这个问题。然后我用从网络服务获得的动态值替换了我想要的角色。然后我把这个字符串写入SD卡和这个文件中的一个新的html文件中,现在我正在加载到Web视图中
I solved the problem by reading the html file in assets folder and put them into string. Then I replaced the character which I wanted to be, with the dynamic value I got from the web service. Then I wrote this string into a new html file inside SD card and this file, now I am loading into web view