onaio / steps-app

WHO STEPS App
Apache License 2.0
2 stars 2 forks source link

DatabaseHelper.java line 74 com.onaio.steps.helper.DatabaseHelper.exec #168

Open ukanga opened 2 years ago

ukanga commented 2 years ago

Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.onaio.steps/com.onaio.steps.activities.HouseholdListActivity}: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1


Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onaio.steps/com.onaio.steps.activities.HouseholdListActivity}: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6669)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)```

Caused by android.database.sqlite.SQLiteException
Can't downgrade database from version 2 to 1
```java
Caused by android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
       at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:522)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:396)
       at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:322)
       at com.onaio.steps.helper.DatabaseHelper.exec(DatabaseHelper.java:74)
       at com.onaio.steps.model.Household.getAllInOrder(Household.java:247)
       at com.onaio.steps.activities.HouseholdListActivity.getViewPreparer(HouseholdListActivity.java:95)
       at com.onaio.steps.activities.HouseholdListActivity.setLayout(HouseholdListActivity.java:53)
       at com.onaio.steps.activities.HouseholdListActivity.prepareScreen(HouseholdListActivity.java:42)
       at com.onaio.steps.activities.BaseListActivity.onCreate(BaseListActivity.java:48)
       at android.app.Activity.performCreate(Activity.java:7136)
       at android.app.Activity.performCreate(Activity.java:7127)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6669)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)```
ndegwamartin commented 2 years ago

I think here we also need to investigate and confirm that this exception was not thrown because we inadvertently added a lower database version on a latter release than one that is already installed (on the device).

That is, I'd expect a similar error if for example:

App on device is version 1 and db is version 2 and New app release is version 2 and db version is 1 cc @hilpitome @owais-vd