Android.database.sqlite.SQLiteException: Cannot downgrade database from 58 to 55 for Android database.

I get this crash in my android application when it tries to read android sms database. The code for reading the sms android database is similar to the following snippet:

String SMS_URI = "content://sms/"; Uri uri = Uri.parse(SMS_URI); Cursor cursor = myContext.getContentResolver().query(uri, null, null, null, null);

This is the only place where my application interacts with the android sms database. Reset error for sms database.

I get the following crash:

  java.lang.RuntimeException: android.database.sqlite.SQLiteException: Can't downgrade database from version 58 to 55 at to.talk.utils.ExceptionThrowingFutureTask$1.run(ExceptionThrowingFutureTask.java:32) at java.lang.Thread.run(Thread.java:856) Caused by: java.util.concurrent.ExecutionException: android.database.sqlite.SQLiteException: Can't downgrade database from version 58 to 55 at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:223) at java.util.concurrent.FutureTask.get(FutureTask.java:82) at to.talk.utils.ExceptionThrowingFutureTask.done(ExceptionThrowingFutureTask.java:22) at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) at java.util.concurrent.FutureTask.setException(FutureTask.java:124) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) ... 1 more Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 58 to 55 at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) at android.content.ContentProviderProxy.query(ContentProviderNative.java:366) at android.content.ContentResolver.query(ContentResolver.java:372) at android.content.ContentResolver.query(ContentResolver.java:315) at to.talk.app.features.growth.SMSReader.readSmsAndGetInviteList(SMSReader.java:39) 

The application works fine in most cases and never crashes locally for me, however it crashes for some users. In devices / environments for which it crashes. I would really appreciate it if someone could help me here.

I found a similar crash here:

[https://crash-stats.mozilla.com/report/list?signature=android.database.sqlite.SQLiteException%3A%20Can%27%27t%20downgrade%20database%20from%20version%2033%20to% 2032% 20at % 20android.database.DatabaseUtils.readExceptionFromParcel% 28DatabaseUtils.java% 29] [1] Although in this case it may be one of their own databases, unlike mine, where the android sms database is located.

+6
source share
2 answers

I can be late for the party, but here are my 2 cents.

The provider you use (the sms device provider) reads and writes to the database, to which you (as a third-party application) do not have access to it. It works like a medium between you.

It seems that the device that received this exception has updated its sms database (or rather, downgraded). This can happen either by updating the version of Android (from the OEM) or by carelessly changing the material with root access.

Sometimes, when a device receives an Android OS update, some things go wrong. Either due to a poor installation, or due to a malfunction. In this case, someone screwed the sms provider.

On the bottom line, you (as the application from the third part) can do nothing about it, an exception completes all your sms provider requests with try-catch). All applications using the same provider must face the same problem as you.

+2
source

download sqlite db file from Android DeviceFileExplorer

[data / data / name of your package / database]

open file with ( DB Browser for SQLite )

go to the " Edit pragmas " tab and downgrade the database version from the user version

finally save the file and upload it to DeviceFileExplorer

enter image description here

0
source

Source: https://habr.com/ru/post/945492/


All Articles