简体   繁体   English

将数据保存在android中以在更新后使用

[英]Save data in android to use after update

I want to save an int and a boolean in my android-app. 我想在我的android-app中保存一个int和一个boolean At the moment I use sharedPreferences to save the variables. 目前,我使用sharedPreferences保存变量。 What happens if I update my app or reinstall it? 如果我更新或重新安装应用程序会怎样?

Should I better use a database for saving the variables? 我是否应该更好地使用数据库来保存变量?

The SharedPreferences will get deleted. SharedPreferences将被删除。 But if you use a BackupAgentHelper (more information here ), you could back up your preferences to the cloud. 但是,如果您使用BackupAgentHelper (更多信息,请BackupAgentHelper 此处 ),则可以将首选项备份到云中。

If you want to do it without internet access, you could save your data to the sd-card. 如果要在没有互联网访问的情况下进行操作,则可以将数据保存到SD卡中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM