简体   繁体   English

将文件保存在/ Download下,其名称为/ storage / emulated / 0 / Download。 有时文件无法访问

[英]Saving file under /Download gives name /storage/emulated/0/Download. Sometimes the file is not accessable

On my Samsung devices I put a file in the /Download folder. 在我的Samsung设备上,我将文件放在/Download文件夹中。 When I select the file within my app (via a file browser), the file is called /storage/emulated/0/Download/myfile.db . 当我在应用程序中(通过文件浏览器)选择文件时,该文件称为/storage/emulated/0/Download/myfile.db This name is stored in my app settings. 此名称存储在我的应用程序设置中。

At the start of the app the file should be opened. 在应用程序启动时,应打开文件。 First the app checks if the file exists. 首先,应用程序检查文件是否存在。 In some cases, say once every 2 weeks, the file is said to be not existing! 在某些情况下,说每2周一次,则说该文件不存在! This happens also at my friends mobile since half a year. 半年以来,我的朋友手机上也发生了这种情况。

Why is that happening? 为什么会这样呢? For years everything ran smoothly. 多年来,一切运行顺利。

This code runs for 6 years. 该代码运行6年。 Of course I added the permissions stuff. 当然,我添加了权限内容。

Your help is much appreciated! 非常感谢您的帮助!

You can't use the Download as an guaranteed storage place for your files. 您不能将下载用作文件的保证存储位置。 You should use the Internal storage for the app. 您应该为应用程序使用内部存储。 This is what Google has written about the download folder: 这是Google关于下载文件夹的内容:

This space is called external because it's not guaranteed to be accessible—it is a storage space that users can mount to a computer as an external storage device, and it might even be physically removable. 该空间称为外部空间,因为它不能保证可以访问-它是用户可以作为外部存储设备安装到计算机的存储空间,甚至可能是物理可移动的。

Here you can read more about the Internal storage and the External storage in Android. 在这里,您可以阅读有关Android 内部存储和外部存储的更多信息。

Here is some more information about the Download folder from Google. 以下是有关从Google 下载文件夹的更多信息

Caution: The external storage might become unavailable if the user removes the SD card or connects the device to a computer. 注意:如果用户卸下SD卡或将设备连接到计算机,则外部存储设备可能不可用。 And the files are still visible to the user and other apps that have the READ_EXTERNAL_STORAGE permission. 用户和其他具有READ_EXTERNAL_STORAGE权限的应用仍然对文件可见。 So if your app's functionality depends on these files or you need to completely restrict access, you should instead write your files to the internal storage . 因此,如果您的应用程序的功能取决于这些文件,或者您需要完全限制访问,则应该将文件写入内部存储

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取 Android 10 及更高版本的路径 /storage/emulated/0/Download/file_name.mime_type - How to get path /storage/emulated/0/Download/file_name.mime_type for Android 10 and above 如何将非媒体文件从 /storage/emulated/0/Download 移动到 getExternalFilesDir() - How to move a non media file from /storage/emulated/0/Download to getExternalFilesDir() FileNotFoundException:/ storage / emulated / 0 / Download /-Android Oreo - FileNotFoundException: /storage/emulated/0/Download/ - Android Oreo 处理请求时捕获到java.io.FileNotFoundException:/document/raw:/storage/emulated/0/Download/mypdf.pdf(没有这样的文件或目录) - java.io.FileNotFoundException caught when processing request: /document/raw:/storage/emulated/0/Download/mypdf.pdf (No such file or directory) 使用Azure存储下载文件并使用简历下载 - Download file using Azure Storage with resume download W/DownloadManager:中止下载请求 17:无法创建目标文件 /storage/emulated/0/Ringtone/Fav_Ringtone.mp3 - W/DownloadManager: Aborting request for download 17: Failed to create target file /storage/emulated/0/Ringtone/Fav_Ringtone.mp3 Android文件下载。 媒体URL不以文件名和类型结尾的问题 - Android file download. Media URLs that does not end with a filename and type, issue 录制的音频无法保存在/ storage / emulated / 0 / AudioRecorder中(有时会出现保存的文件,有时不会出现) - Recorded Audio Can't be saved in /storage/emulated/0/AudioRecorder (sometimes saved file appear, sometimes not appear) 如何从 firebase 存储中的下载链接获取文件名? - How to get file name from download link in firebase storage? /storage/emulated/0/Notes/(没有那个文件或目录)? - /storage/emulated/0/Notes/ (No such file or directory)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM