Reputation: 339
So I have an application on the market place. It's been running fine for several months. I've updated it twice with small bug fixes and made no change to the database what so ever.
Some of my users are getting the following error:
android.util.Log$TerribleFailure: Can t downgrade read-only database from version 2 to 1: /data/data/myapp/databases/MyAppDB
at android.util.Log.wtf(Log.java:275)
at android.util.Log.wtf(Log.java:254)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129)
As I mentioned, there has been no change to the database if any of the updates. It obviously crashes when the getWriteableDatabase method is called. I'm stumped as to why this error is occurring.
My best guess is that the user's phone has no more space left and thus a writable database can't be openend and thus crashes the app.
Any ideas?
Upvotes: 2
Views: 1180
Reputation: 73375
A sqlite database has a version number. The version number is set when you open the database.
For example, if you use SQLiteOpenHelper
, the constructor has int version
parameter.
The error you get happened because on the user's device there is an old database with version=2 set, but on your program update you are trying to open that old database requesting version=1. That's not allowed.
Just set the version on the updated program to 2 or more.
Upvotes: 2