Skip to content

🔥 【置顶】获取路径为空的问题(Path return null problem) #49

Description

@javakam

✨基本上每一个issue都会提到的问题👉Android Q及以上版本获取路径为空

🌴测试环境 API 30 , Android 11.0

Video_2021-09-07_155012.convert-video-online.com.mp4

🍎 可以看到, 同一文件会有两种不同的 Uri :

  1. 从侧边栏手机图标进入时获取到文件的Uricontent://com.android.externalstorage.documents/...,此时路径不为空;
  2. 从侧边栏Download进入时Uricontent://com.android.providers.downloads/..., 此时路径为空。

🌴建议使用Uri替换Path, 如上传文件操作可以使用ContentResolver.openInputStream/openFile/...等API操作, 唯一缺点是不能显示文件路径, 但不会影响功能使用。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions