Android:更新应用程序后保留内部文件 [英] Android: Keep internal files after updating app
问题描述
我见过很多实例,人们声称更新Android应用不会不删除其内部文件.但是,我正在分别使用 openFileInput()
和 openFileOutput()
读取和创建文件,效果很好,直到更新了应用程序,在该文件中显然无法找到文件已读取或已删除.
I've seen multiple instances where people claim that updating an Android app does not remove its internal files. However, I'm reading and creating a file using openFileInput()
and openFileOutput()
respectively, which works fine, until the app is updated where apparently the file can not be read, or is deleted.
在开发游戏时,我想避免使用 SharedPreferences
.
As I'm developing a game, I would like to avoid SharedPreferences
.
由于保存进度或多或少是强制性的,写到外部位置会是更好的选择吗?尽管该用户可以篡改该文件(它是序列化文件),但不应.
As saving progress is more or less mandatory, would writing to an external location be a better alternative? The user shouldn't although be able to tamper with the file (its a serialisation).
否则,是否有办法在更新后保留内部文件?谢谢
Otherwise, is there a way to keep the internal file after updating? Thanks
推荐答案
为什么不为此目的使用SQLite数据库.除非您明确指示要更改或删除应用程序,否则更新应用程序将使数据库保持不变.
Why do you not use an SQLite database for this purpose. Updating the app will leave the database untouched unless you explicitely instruct your app to change or delete it.
这篇关于Android:更新应用程序后保留内部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!