使用DownloadManager下载文件时出现SQLite异常

时间:2017-04-19 10:45:20

标签: android sqlite

我的应用程序使用DownloadManager逐个下载.mp3文件。通常它按预期工作。但有时下载挂起并且进度条停止在DownloadManager通知中更新。如果我现在点击通知 - 我的应用程序崩溃了SQLiteCantOpenDatabaseException:

04-19 17:18:11.167 4533-29108/android.process.media E/SQLiteLog: (14) cannot open file at line 30059 of [b3bb660af9]
04-19 17:18:11.177 4533-29108/android.process.media E/SQLiteLog: (14) os_unix.c:30059: (24) open(/data/data/com.android.providers.downloads/databases/downloads.db-journal) - 
04-19 17:18:11.177 4533-29108/android.process.media E/SQLiteLog: (14) cannot open file at line 30059 of [b3bb660af9]
04-19 17:18:11.177 4533-29108/android.process.media E/SQLiteLog: (14) os_unix.c:30059: (24) open(/data/data/com.android.providers.downloads/databases/downloads.db-journal) - 
04-19 17:18:11.177 4533-29108/android.process.media E/SQLiteLog: (14) statement aborts at 11: [SELECT _id, bypass_recommended_size_limit, uri FROM downloads WHERE (_id = ?)] unable to open database file
04-19 17:18:11.177 4533-29108/android.process.media E/SQLiteQuery: exception: unable to open database file (code 14); query: SELECT _id, bypass_recommended_size_limit, uri FROM downloads WHERE (_id = ?)
04-19 17:18:11.437 4533-4551/android.process.media E/SQLiteLog: (14) cannot open file at line 30059 of [b3bb660af9]
04-19 17:18:11.447 4533-4551/android.process.media E/SQLiteLog: (14) os_unix.c:30059: (24) open(/data/data/com.android.providers.downloads/databases/downloads.db-journal) - 
04-19 17:18:11.447 4533-4551/android.process.media E/SQLiteLog: (14) cannot open file at line 30059 of [b3bb660af9]
04-19 17:18:11.447 4533-4551/android.process.media E/SQLiteLog: (14) os_unix.c:30059: (24) open(/data/data/com.android.providers.downloads/databases/downloads.db-journal) - 
04-19 17:18:11.447 4533-4551/android.process.media E/SQLiteLog: (14) statement aborts at 49: [SELECT _id, _data AS local_filename, mediaprovider_uri, destination, title, description, uri, status, hint, mimetype AS media_type, total_bytes AS total_size, lastmod AS last_modified_
04-19 17:18:11.447 4533-4551/android.process.media E/SQLiteQuery: exception: unable to open database file (code 14); query: SELECT _id, _data AS local_filename, mediaprovider_uri, destination, title, description, uri, status, hint, mimetype AS media_type, total_bytes AS total_size, lastmod AS last_modified_timestamp, current_bytes AS bytes_so_far, allow_write, errorMsg, notificationpackage, 'placeholder' AS local_uri, 'placeholder' AS reason, entity, file_create_time, downloading_current_speed, download_surplus_time, xl_accelerate_speed, downloaded_time, xl_vip_status, xl_vip_cdn_url, xl_task_open_mark, download_task_thumbnail, apk_package_name, errorMsg, notificationpackage, download_file_hash, download_apk_install_way, download_extra, download_speedup_time, download_speedup_status, download_speedup_mode FROM downloads WHERE ((status='192') AND deleted != '1') ORDER BY _id DESC
04-19 17:18:11.457 4533-4551/android.process.media E/DatabaseUtils: Writing exception to parcel
                                                                    android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
                                                                        at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
                                                                        at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:845)
                                                                        at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
                                                                        at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
                                                                        at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:146)
                                                                        at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:135)
                                                                        at android.database.CursorToBulkCursorAdaptor.getBulkCursorDescriptor(CursorToBulkCursorAdaptor.java:145)
                                                                        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:122)
                                                                        at android.os.Binder.execTransact(Binder.java:446)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err: android.database.sqlite.SQLiteException: unable to open database file (code 14)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at android.content.ContentResolver.query(ContentResolver.java:501)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at android.content.ContentResolver.query(ContentResolver.java:436)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at com.android.providers.downloads.marketRelease.XLDownloadManager$Query.runQuery(XLDownloadManager.java:1319)
04-19 17:18:11.457 16692-28705/android.process.mediaUI W/System.err:     at com.android.providers.downloads.marketRelease.XLDownloadManager.query(XLDownloadManager.java:1471)

我知道DownloadManager应管理所有下载并在下载失败时重新启动它们。我没有在我的应用程序中使用SQLite,因此我认为DownloadManager是导致问题的人。

那么什么崩溃了DownloadManager?我可以阻止它从我的代码中崩溃吗?还有办法阻止我的应用程序崩溃吗?

0 个答案:

没有答案