亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android檔案存在()無法運作

Android檔案存在()無法運作

素胚勾勒不出你 2021-04-07 15:08:06
目前,我目前正在嘗試從中下載文件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);我嘗試進行文件檢查,查看文件是否存在,但是即使文件已經下載且位于正確的位置,我也總是得到文件不存在的信息。有人可以幫我弄這個嗎?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 169 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號