设置setDestinationInExternalPublicDir()
时应用程序崩溃
val videoDir = Environment.getDataDirectory().absolutePath + "/applicationfiles/.tutorial"
downloadRequest.setDestinationInExternalPublicDir(videoDir, videoName)
E / AndroidRuntime:致命异常:主要流程:app.package,PID:19275java.lang.IllegalStateException:不是标准目录之一:/data/applicationfiles/.tutorial在android.os.Parcel.createException(Parcel.java:2079)在android.os.Parcel.readException(Parcel.java:2039)在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)在android.content.ContentProviderProxy.call(ContentProviderNative.java:658)在android.content.ContentProviderClient.call(ContentProviderClient.java:558)在android.content.ContentProviderClient.call(ContentProviderClient.java:546)在android.app.DownloadManager $ Request.setDestinationInExternalPublicDir(DownloadManager.java:569)在app.package.startDownloadingFile(ExerciseTutorialPresenter.kt:159)在app.package.downloadVideoFiles(ExerciseTutorialPresenter.kt:142)
setDestinationInExternalPublicDir(dirType: String!, subPath: String!)
对于面向Android 10及更高版本的应用程序,此方法的第一个参数setDestinationInExternalPublicDir(dirType: String!, subPath: String!)
必须是已知的公共目录之一,例如dirType
,Environment.DIRECTORY_DOWNLOADS
,Environment.DIRECTORY_PICTURES
等