目前,我目前正在尝试从中下载文件Uri,但我想这样做,以便如果文件已下载,将无法再下载。所以我决定使用file.exists()它来做,但是现在由于file.exists()某种原因该方法不起作用。Uri uri = Uri.parse("http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf");Uri path = Uri.parse("file:///storage/emulated/0/Download/");String test = uri.getPath();File file = new File(path.getPath());File check = new File(path.getPath()+uri.getLastPathSegment());if (!check.exists()||!check.isFile()) { DownloadManager.Request request = new DownloadManager.Request(uri); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(String.valueOf(file), uri.getLastPathSegment()); Long reference = downloadManager.enqueue(request);}Intent intent = new Intent(MainActivity.this,ViewActivity.class);intent.putExtra("book",""+uri.getLastPathSegment()+"");startActivity(intent);我尝试进行文件检查,查看文件是否存在,但是即使文件已经下载且位于正确的位置,我也总是得到文件不存在的信息。有人可以帮我弄这个吗?
添加回答
举报
0/150
提交
取消