android.database.sqlite.SQLiteException导致无法打开数据库文件(代码14)

时间:2018-04-09 10:33:27

标签: android android-sqlite android-download-manager

从Crashlytics我得到例外,我正在使用下载管理器下载文件:

这是代码:

 DownloadManager.Request request = new DownloadManager.Request(
                Uri.parse(videoURL));


        File folder = new File(dir + "" + File.separator + (isAudio ? AUDIO : IMAGES));
        if (folder == null) {
            return;
        }
   try {
                request.setAllowedNetworkTypes(
                        DownloadManager.Request.NETWORK_WIFI
                                | DownloadManager.Request.NETWORK_MOBILE)
                        .setAllowedOverRoaming(false)
                        .setTitle("Test")
                        .setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
                        .setDescription(id)
                        .setDestinationInExternalFilesDir(context, isAudio ? AUDIO : IMAGES, fileName);
            } catch (IllegalStateException e) {
            } catch (Exception e) {
            }

                enqueue = downloadManager.enqueue(request);

这是来自logcat的堆栈跟踪:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:325)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)


Caused by android.database.sqlite.SQLiteException: unable to open database file (code 14)
       at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179)
       at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
       at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
       at android.content.ContentResolver.insert(ContentResolver.java:1279)
       at android.app.DownloadManager.enqueue(DownloadManager.java:1021)
       at PACKAG_NAME.FrontEngine.enqueueDownload(FrontEngine.java:1041)
       at PACKAG_NAME.ChatActivity.downloadMessageFile(ChatActivity.java:575)
       at PACKAG_NAME.BaseActivity.downloadFilesFromConversationItem(BaseActivity.java:1117)
       at PACKAG_NAME.BaseActivity$6.doInBackground(BaseActivity.java:751)
       at android.os.AsyncTask$2.call(AsyncTask.java:305)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)

我找不到原因,它在40多台设备上工作正常,只报告了一次崩溃,我也拒绝了申请许可,但工作正常。 任何人都可以对它有所了解。我应该在try catch中使用put enqueue方法吗?

0 个答案:

没有答案