WebView 및 DoanloadManager를 사용하여 글꼴을 다운로드하려고합니다. Environment.getExternalStorageDirectory() + "/Fonts/"
을 사용하여 다운로드 폴더 디렉토리를 "Fonts"폴더로 설정했지만 대신 다른 원치 않는 디렉토리 인 sdcard/storage/emulated/0/Fonts/
을 만듭니다. 내 코드에 어떤 문제가 있습니까? 여기에 전체 코드 조각은 다음과 같습니다Environment.getExternalStorageDirectory가 잘못된 경로를 반환하는 이유는 무엇입니까?
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
String filename = URLUtil.guessFileName(url, contentDisposition, mimeType);
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
request.setMimeType(mimeType);
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
request.addRequestHeader("User-Agent", userAgent);
request.setDescription("Downloading file...");
request.setTitle(filename);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory() + "/Fonts/", filename);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
실제 장치 대신 에뮬레이터에서 코드를 실행하고 있습니까? –