Can't downgrade database from version 2 to 1 even after fresh install and re-run

后端 未结 10 981
离开以前
离开以前 2020-12-16 01:14

I\'m writing an android app using SQLite DB.

I had few experiments and changed the DB version from 1 to 2.

Then my DB schema became stable and because i didn

相关标签:
10条回答
  • 2020-12-16 01:53

    You don't show where the database is created, which is where the database version is normally assigned (i.e. SQLiteOpenHelper ctor).

    Is there any chance you have the database on external file system? Unless you follow the naming conventions, these files are not deleted when the application is removed.

    0 讨论(0)
  • 2020-12-16 01:57

    Update: Go to app info and > Storage and clear data should worke as well.

    One possible reason it worked first time but not second time could be that the database wasn't called in the first run?

    Also from Marshmallow, Android app data is automatically backed up. for apps targeting 23+ so your app could have gotten the previous database from the cloud without you knowing.

    Unfortunately, you can't yet delete app data individually. But if you don't mind killing your backed up data for all apps, you can uninstall the app then go to https://myaccount.google.com/dashboard and expand the Android section and delete backed up app data.

    After that, you should be able to re-install the app and get a fresh new database.

    This worked for me, but do so at your own risk.

    0 讨论(0)
  • 2020-12-16 01:59

    onDowngrade() is not overridden in your code. You should handle onDownGrade().

    0 讨论(0)
  • 2020-12-16 02:03

    This means that there is already a previous file and you are trying to create another one with the same name, you can change the name of the database, or on the device you are emulating uninstall the application, and emulate it again.

    0 讨论(0)
提交回复
热议问题