在应用程序更新/重新安装推出 Xamarin 上保留 SQLite 数据库数据 [英] Preserving SQLite db data on App Update/Reinstall Rollout Xamarin

查看:33
本文介绍了在应用程序更新/重新安装推出 Xamarin 上保留 SQLite 数据库数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Xamarin.Forms 共享项目,我目前正在 Android 手机上测试该项目.

I have Xamarin.Forms shared project that I am testing on Android phone currently.

截至目前,sqlite 数据库存储在 System.Environment.SpecialFolder.Personal 中.

The sqlite db is stored in System.Environment.SpecialFolder.Personal as of now.

我想确保保存在 db 中的用户输入数据:

I want to make sure that user input data stored in db is preserved:

(我猜这是两种完全不同的情况,但我可能是错的)

(I guess these are two totally different situations, but I might be wrong)

我想知道通过 Google Play Store Update 更新应用程序是否也会覆盖 db 文件,从而丢失所有数据?还是会保留数据?

I would like to know whether an update of an App via Google Play Store Update will overwrite db file too, therefore all data be lost? Or will the data be preserved?

如果用户想要在卸载/重新安装应用后保留他/她的数据,有什么选择?

What would be the option if a user wanted to preserve his/her data even after an app Uninstall/Reinstall?

在第二种情况下,我正在考虑手动/自动备份正在使用的 SpecialFolder.Personal db 版本,并使用 External_STORAGE 权限将其存储为包外的单独文件.

In second case, I am considering manual/automatic backup of SpecialFolder.Personal db version in use and storing it as a separate file outside of the package using External_STORAGE permissions.

然后用户将能够从外部数据库文件副本中导入数据到包中.

Then the user will be able to Import data from external db file copy into the one that comes in the package.

另外,导入应该是什么样子的?我可以简单地用外部文件替换文件吗?

Also, how should the Import look like? Can I simply replace the file with external one?

非常感谢有关此主题的任何建议.

Any advice on this topic will be very appreciated.

推荐答案

  1. 来自 Google Play 的更新不会覆盖数据库文件
  2. 如果用户卸载该应用程序,他将希望删除与该应用程序相关的所有内容.所以我最好的解决方案是在你的 API 中使用一个同步方法,这样当用户再次安装应用程序时,它会用请求的数据填充本地数据库.

这篇关于在应用程序更新/重新安装推出 Xamarin 上保留 SQLite 数据库数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆