android - 在 Android 上加载文件

标签 android file android-sdcard

我想在我的 android 项目中从 sdcard 加载一个文件 wav,但我没有成功。 我正在使用

File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"/mnt/sdcard/.....wav");

但是我得到了这个错误

java.io.FileNotFoundException: /mnt/sdcard/mnt/sdcard/......wav (No such file or directory)

你能帮帮我吗?

最佳答案

第一个参数已经是路径-不要把/mnt/sdcard/放到第二个参数中

File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,".....wav");

关于android - 在 Android 上加载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24862919/

相关文章:

android - Gradle 错误 : ProductFlavor names cannot start with 'test'

java - 将 JSON 作为 HTTP POST 参数发送 (Android/Java)

image - 将 native 上传图像 react 为文件

android - 如果Android目录尚不存在,如何自动创建它

java - 在 android 中调用 facebook 页面的正确方法?

android - 使用 Glide 将图像加载到 ImageView 中,Uri 从 Intent 返回, Action 为 ACTION_GET_CONTENT

android - 如何知道 sdcard 有足够的可用空间写入 Android?

android - 读/写可移动SD卡(android模拟器)

iphone - 在 objective-c 中只从磁盘读取文件的一部分

c++ - 读取包含 16 位签名数据的文件