0

I am using GreenDao, if that matters.

If my phone has my app on it already, and I update my app to, for example, add a new field to a database and then use that field in my code, and I re-download my app, it'll crash because it doesn't automatically update the database.

How do I get the new app to also update the database?

  • you need to upgrade your database and give a new version number. see here:http://stackoverflow.com/questions/8133597/android-upgrading-db-version-and-adding-new-table – Opiatefuchs Apr 13 '17 at 16:22
  • But if I give my app a new version number, wouldn't that look weird by the time I put it online? "Download My App, version v25"... "what about versions 1-24?" – user7863308 Apr 13 '17 at 16:26
  • well there is no workaround if you change something on your database, you have to update your app everytime. As soon as you add a new column, you must upgrade the database. And also all the stuff that you made to query the entries must be updated.... – Opiatefuchs Apr 13 '17 at 16:31
  • So even when you're developing your app you either have to get it all right the very first time or you have to publish an app with a bigger version number? – user7863308 Apr 13 '17 at 16:36
  • not by developing.....if it´s not published, you just have to delete the old database.... – Opiatefuchs Apr 13 '17 at 16:39
  • if your device is not rooted and you are not able to delete the database, just uninstall your app and start again... – Opiatefuchs Apr 13 '17 at 16:45
  • I don't understand. If I am developing, I am testing it on my phone. Are you saying that I need to be deleting / re-installing the app from scratch every time I change the database to keep it at version 1? – user7863308 Apr 13 '17 at 16:57
  • yes.....if you add a column...if you just manipulate an entry then it´s not necessary. Only if you touch the structure of the database.... – Opiatefuchs Apr 13 '17 at 17:01

0 Answers0