目前,我目前正在嘗試從中下載文件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
提交
取消