Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.database.sqlite.SQLiteException: Can't downgrade database from version 58 to 55 for android sms database

I get this crash in my android application when it tries to read the android sms database. The code for reading the android sms 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. The downgrade error is being thrown for the 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 most of the time and never crashes for me locally, however it crashes for some of the users. There are no noticeable patterns in the devices\environments for which it crashes. I would really appreciate if someone could help me out here.

I found a similar crash here.

Though in this case it might be one of their own databases unlike mine where its the android sms database.

like image 412
Tarang Shrivastava Avatar asked May 21 '13 12:05

Tarang Shrivastava


1 Answers

I might be late to the party, but here are my 2 cents.

The provider you are using (the sms provider of the device) reads and writes to a database that you (as a 3rd party app) have no access to it. It works as a medium between the two of you.

It looks like that the device that got this exception had its sms database updated (or to be more precise downgraded). This can happen either by a Android version upgrade (by a OEM) or by carelessly changing stuff while having root access.

Sometimes, when a device gets a Android OS update, some stuff go wrong. Either because of a bad installation, or because the update is buggy. In this case, someone screwed the sms provider.

Bottom line, you (as a 3rd part app) can do nothing about it, exception wrapping all your sms provider queries with try-catches). All apps that use the same provider should face the exact same issue as you.

like image 124
Alex Styl Avatar answered Oct 12 '22 18:10

Alex Styl