Android:保存下载文件的位置? [英] Android: where are downloaded files saved?

查看:114
本文介绍了Android:保存下载文件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个文档管理器

I am trying to develop a "document manager"

我有必要访问从互联网下载的文件,Gmail,其他邮件客户端,其他互联网来源...

I have the necessity of accessing the files downloaded from the internet, from Gmail, for other mail clients, from other internet sources...

我想了解这些文件是否完全存储在Android上:

1-如果有SD

2-如果没有SD卡

,以便我可以随时向我的应用程序显示给用户。

so that I can show them to the user in my App at any time.

任何帮助非常感谢。

推荐答案

大多数设备都有某种形式的模拟存储。如果他们支持sd卡,通常将它们安装到 / sdcard (或该名称的某些变体),通常符号链接到 / storage / storage / sdcard0 / storage / 0 有时模拟的存储装载到 / sdcard ,实际路径类似于/ storage / emulated / legacy。您应该可以使用来获取下载目录。你最好使用api调用来获取目录。
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

Most devices have some form of emulated storage. if they support sd cards they are usually mounted to /sdcard (or some variation of that name) which is usually symlinked to to a directory in /storage like /storage/sdcard0 or /storage/0 sometimes the emulated storage is mounted to /sdcard and the actual path is something like /storage/emulated/legacy. You should be able to use to get the downloads directory. You are best off using the api calls to get directories. Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

由于文件系统和sdcard支持因设备而异。

Since the filesystems and sdcard support varies among devices.

查看更多信息的相似问题如何访问android中的下载文件夹

see similar question for more info how to access downloads folder in android?

通常,DownloadManager处理下载,然后通过从下载管理器请求文件的uri来访问文件一个文件ID,以获取文件是通常位于sdcard / real或模拟的地方,因为应用程序只能从其数据目录之外的文件系统的某些位置读取数据,如sdcard

Usually the DownloadManager handles downloads and the files are then accessed by requesting the file's uri fromthe download manager using a file id to get where file was places which would usually be somewhere in the sdcard/ real or emulated since apps can only read data from certain places on the filesystem outside of their data directory like the sdcard

这篇关于Android:保存下载文件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆