【问题标题】:Unable to get a File handle for a URI that starts with "content://0@media/"无法获取以“content://0@media/”开头的 URI 的文件句柄
【发布时间】:2019-03-05 12:48:45
【问题描述】:

为了访问视频并通过我们的应用程序共享它,我正在尝试使用 FileProvider 访问它。该代码适用于所有 URI,但以“content://0@media/”开头的 URI 除外。在这种特定情况下,检查“vidFile.exists()”返回 false。请让我知道如何访问具有此类内容 URI 的文件。感谢您的帮助。

File vidFile = new File(uri.getPath());
if (vidFile.exists()) //This is returning false for this content URI
{
    Uri vidUri = FileProvider.getUriForFile(
            context,
            context.getString(R.string.file_provider_authority),
            vidFile);
}

【问题讨论】:

  • 它不是一个文件。你已经有一个contentUri,所以你不需要FileProvider。
  • 谢谢,我用了getContentResolver().query,可以得到视频属性了。

标签: android android-fileprovider


【解决方案1】:

我使用了 getContentResolver().query 并且可以获得视频属性。不需要像 CommonsWare 评论的那样使用 FileProvider。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 2023-03-07
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多