【问题标题】:How to post audio file to server in android如何在android中将音频文件发布到服务器
【发布时间】:2014-09-26 15:21:50
【问题描述】:

我需要将音频文件(从音频/* 意图中挑选)发布到服务器。这里我得到了 Uri,但发布参数类型是 File。我使用了下面的代码,但它显示 /directory/.. 不是绝对路径并且得到FileNotFoundException。任何人都建议我..

代码:

Uri uri=data.getData();

File f=new File(uri.getPath());

日志:

09-26 21:20:19.735: I/System.out(920): java.io.FileNotFoundException: /document/audio:5257: open failed: ENOENT (No such file or directory)

【问题讨论】:

    标签: android file audio filenotfoundexception


    【解决方案1】:

    (这是重复的)

    请看这里: Convert file: Uri to File in Android

    不要使用 Uri::ToString() 而是使用 Uri::getPath()。

    【讨论】:

    • 它显示 filenotfound 异常我使用 getPath() 查看编辑代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-22
    • 2012-01-27
    相关资源
    最近更新 更多