简体   繁体   English

Android-SQLite数据库-应用程序更新

[英]Android - SQLite Database - App update

So I got a sqlite database (version 7) which stores data for my App (version 1.0) and I want to fix a few bugs (that have nothing to do with my database). 因此,我有了一个sqlite数据库(版本7),该数据库存储了我的应用程序(版本1.0)的数据,并且我想修复一些错误(与数据库无关)。 What happens if I update my App to version 1.1? 如果我将我的应用更新到版本1.1,会发生什么? will the data be deleted? 数据将被删除吗? or will it just be deleted if i update the databse version to 8? 还是将databse版本更新为8,将其删除?

(My onUpgrade in the databasehandler will delete the existing databse and create a new one by the way) (我在数据库处理程序中的onUpgrade将删除现有的数据库并创建一个新的数据库)

Upgrading an app does not do anything to the database. 升级应用程序不会对数据库执行任何操作。 Old data files are kept intact. 旧数据文件保持不变。

Changing the version number in code for your SQLiteOpenHelper will cause onUpgrade() to be called if the version number in the database file is lower. 如果数据库文件中的版本号较低,那么在SQLiteOpenHelper代码中更改版本号将导致调用onUpgrade() That by itself doesn't delete anything, but if you yourself delete the data (as you say), then it is lost. 它本身不会删除任何内容,但是如果您自己删除数据(如您所说),则数据将丢失。

See also: When is SQLiteOpenHelper onCreate() / onUpgrade() run? 另请参阅: SQLiteOpenHelper onCreate()/ onUpgrade()何时运行?

Data will delete if you change the version, but in onUpgrade method we have two parameters 如果更改版本,数据将删除,但是在onUpgrade方法中,我们有两个参数

called oldVersion and newVersion. 分别称为oldVersion和newVersion。 we can do what ever we want by checking old new version 我们可以通过检查旧的新版本来做我们想做的事情

condition. 条件。

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

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