android - 使用模拟器时android的文件路径

标签 android download

我是安卓新手。我正在尝试从服务器下载文件并将文件保存在特定路径中。该应用程序工作正常。但是我找不到下载文件的路径。在我给出的代码中

文件输出=新文件("/data/data/com.test.firstApp/", fileName);

我在哪里可以找到我系统上的文件?

最佳答案

不要使用硬编码文件路径。该框架将为您提供要将文件保存到的区域的基本路径。

对于 SD 卡,使用 Environment.getExternalStorageDirectory()

对于本地文件,使用Context.getFilesDir()(或Context.openFileOutput(String name, int mode)等)

对于本地缓存,使用Context.getCacheDir()

关于android - 使用模拟器时android的文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703619/

相关文章:

android - 带有建议列表的 TextView

r - 如何在 Shiny 的一个下载按钮中下载多个 png 图

android - 简单游标适配器查询

java - Android Set 上的 ConcurrentModificationException

c# - 下载后文本文件错误

c# - 提供匿名下载网址的方法

lua - Oneliner 从在线加载 Lua 脚本(Gist)并在当前上下文中运行

android - 是否可以在 Android DownloadManager 中提交 cookie

c# - 如何在 Xamarin 中添加计时器?

android - 错误 :Failed to open zip file. Gradle 依赖项缓存可能已损坏(这有时会在网络连接超时后发生。)