-3

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.

Thank you!

centinno
  • 1
  • 1
  • Your data will not be lost, test your application before you upload to Play Store. Also that it would be helpful if you post your onUpgrade method from the SQLite helper class – Skynet Mar 05 '15 at 05:28
  • 1
    possible duplicate of [How to update table schema after an app upgrade on Android?](http://stackoverflow.com/questions/2232321/how-to-update-table-schema-after-an-app-upgrade-on-android) – BrentM Mar 05 '15 at 05:34

1 Answers1

0

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.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127