我访问下载文件夹,但无法访问android上下载文件夹中的文件 [英] I access the download folder but I cannot access the files in the download folder on android
本文介绍了我访问下载文件夹,但无法访问android上下载文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我访问下载文件夹,但无法访问android上下载文件夹中的文件.我想检查下载文件夹中的文件是否存在.例如,当我想从互联网上下载一个名为example.txt的文件时,我想检查该文件是否在下载文件夹中.我寻找了许多解决方案,但找不到.谢谢
I access the download folder but I cannot access the files in the download folder on android. I want to check the present of a file in the download folder. For example, when I want to download a file named example.txt from the internet, I want to check if that file is in the download folder. I looked for many solutions but I couldn't find. Thanks
File dir= new File(Environment.
getExternalStoragePublicDirectory(Environment
.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/example.pdf");
if(dir.exists()) {
Toast.makeText(getApplicationContext(), "File Already Exists",
Toast.LENGTH_LONG).show();
}
推荐答案
如果在Android10中使用,则可以尝试以下代码.
You can try below code if using in Android10.
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
这篇关于我访问下载文件夹,但无法访问android上下载文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文