0

Over the last couple of years, I have been creating an app for a customer (also the reason that I unfortunately cannot share the code on here). The last version uploaded to the play store was targeted at API 25, and was published around July 2017.

I am currently testing a new update, and am finding that opening the database via the SQLiteOpenDatabase is causing the onCreate function to run. The data from the previous version of the app gets lost. I have installed the previous version of the app both via the play store and manually, but the upgrade is always performed directly from the new versions APK.

Data stored on intermediate development versions of the app doesn't get lost, but they all erase data from the currently released version.

The classes for managing the database haven't changed, and are using the same version code for the database. I have checked the certificates, and all versions have been signed with the same one.

Is anyone aware of other reasons that the database may be recreated? This is a serious issue, that is preventing the release of the application.

adzy2k6
  • 105
  • 1
  • 10
  • Please increase your database version by one. – Shalu T D Mar 23 '18 at 14:45
  • I attempted that and found the same behaviour. Just to be clear, I am not trying to get the onUpgrade method to run, but to stop it from calling the onCreate method. I suspect that installing the update is causing stored data to be removed. – adzy2k6 Mar 23 '18 at 14:48
  • Have you changed the database file name? – laalto Mar 23 '18 at 14:49
  • The database name is the same. I am using the class from https://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#onCreate(android.database.sqlite.SQLiteDatabase), with the first form of the constructor. – adzy2k6 Mar 23 '18 at 14:59
  • There's the generic answer here: https://stackoverflow.com/a/21881993/101361 – laalto Mar 23 '18 at 15:36

0 Answers0