【问题标题】:Load File on Android在 Android 上加载文件
【发布时间】:2014-09-11 19:54:55
【问题描述】:

我想在我的 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)

你能帮帮我吗?

【问题讨论】:

  • 你看的路径中没有这样的文件或目录,也给权限

标签: android file android-sdcard


【解决方案1】:

从行中删除这个/mnt/sdcard/ 它已经存在于file

替换这个:

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

用这个:

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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

    • 很高兴我能帮上忙——也许你可以接受这个答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-21
    • 1970-01-01
    • 2015-10-23
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多