更新Play商店中的应用

更新Play商店中的应用

问题描述:

我是新的android开发,我开发了具有存储在SQLite数据库的表单(姓名,地址)的应用程序,这是第一个版本。在第二个版本我添加电子邮件域。我想问一下我是如何使更新的时候我做了一个upgrad到第二个版本存储在第一个版本中的数据不被破坏。

I'm new to android development, I developed an application that has a form (name, address) stored in a SQLite database, that's for the first version. In the second version I add an email field. I would like to ask how I did to make the update for the data stored on the first version are not destroyed when I made an upgrad to the second version.

感谢您!

如果您使用的是提供SQLHelper类,更新版本,在功能的onUpdate执行ALTER TABLE SQL命令来添加电子邮件域。你必须使它成为一个可空场,因为现有的行不会拥有它。然后,如果你拥有了它,发送更新命令将电子邮件添加到行。

If you're using the SQLHelper class, update the version, and in the onUpdate function perform an ALTER TABLE sql command to add the email field. You'll have to make it a nullable field, as the existing rows won't have it. Then, if you have it, send UPDATE commands to add the emails to the rows.