嗨stackoverflow
我正在尝试获取邮件总数,但我只是从少数用户那里得到以下例外。
此问题也在stackoverflow
中的以下链接android.database.sqlite.SQLiteException: Can't downgrade database from version 58 to 55 for android sms database
我正在使用以下代码
private void totalSMS()
{
try{
Uri allMessages = Uri.parse("content://sms/");
Cursor c = getContentResolver().query(allMessages, null, null, null, null);
totalMessages = 0;
while (c.moveToNext())
{
String messageBody = c.getString(c.getColumnIndex("body"));
long messageLength = messageBody.length();
double numberOfMessages = messageLength / 160.0;
double numberOfMessagesRoundedUp = Math.ceil(numberOfMessages);
totalMessages = (int) (totalMessages + numberOfMessagesRoundedUp);
}
}catch(Exception e){
totalMessages = 0;
}
}
我正在关注crash
信息
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
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)
请帮我解决这个谜题。
感谢。