更新 apk 附带的特定文件?
我想知道是否有任何方法可以更新最初发布的包(apk)中的特定文件?
就我而言,我需要确保下载 apk 时应用程序附带某个文本文件。但是,我希望能够远程更新该文本文件并仅替换该文本文件,而不是整个 apk 文件。
您可以编写和创建所谓的“内部存储”中的文件,但如何首先将文本文件放置在那里;也就是说,如何确保文本文件位于“内部存储”中,以便在安装 apk 后可以使用 openFileInput(...) 读取它?
因为如果我可以将文本文件放在“内部存储”中,以便可以通过 openFileInput 访问它,那么我以后可以轻松地覆盖它,但它必须首先存在=)。
I'd like to know if there is any way to update a specific file in the package (apk) that was originally shipped?
In my case I need to make sure that a certain text file comes with the app when downloading the apk. However, I want to be able to update that text file remotely and replace only that text file, not the entire apk-file.
you can write and create files that are in the so called "internal storage", but how do I place the text file there in the first place; that is, how do I make sure that the text file is in the "internal storage" so I can read it with openFileInput(...) after the install of the apk?
Because if I can place the text file in "internal storage" so it can be reached by openFileInput, I can easily overwrite it later, but then it has to be there in the first place =).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望能够更新文本文档,而无需在每次更新文本文档时更新整个 apk,那么您需要将文本文档托管在网站上,并让 apk 获取文档。您可以创建一个警报来触发,然后让广播接收器检索文档并将其存储到应用程序中。或者您可以将文本文档放在网站上(谷歌网站是免费的)并让应用程序从中读取数据,并将数据存储在 SharedPreference 中。
如果您需要有关如何从文本文档中读取内容的代码,请告诉我。当我将这个过程用于我的一个应用程序时。它工作完美。
If you want to be able to update the text doc without updating the entire apk each time you updated the text doc, then you will need to host the text doc on a website and have the apk fetch the document. You could create an alarm to fire off and then have a broadcast reciever retrieve the document and store it to the app. Or you could have the text doc on a website(google site is free) and have the app read from it, and store the data in a SharedPreference.
If you need code on how to read from a text doc let me know. As i use this process for one of my apps. It works perfect.