设备在 pre-KitKat 设备上重启后的 Uri 权限?

Uri permissions after the device reboot on pre-KitKat devices?

有很多关于如何使用新的 API >= 19 权限模型的问题和答案,但我一直想知道相反的情况——我应该如何从内容中读取文件内容已向我的应用程序授予 read/write 权限且设备出于某种原因重新启动的提供商?

Android 文档 says:

ACTION_OPEN_DOCUMENT is not intended to be a replacement for ACTION_GET_CONTENT. The one you should use depends on the needs of your app:

Use ACTION_GET_CONTENT if you want your app to simply read/import data. With this approach, the app imports a copy of the data, such as an image file.

Use ACTION_OPEN_DOCUMENT if you want your app to have long term, persistent access to documents owned by a document provider. An example would be a photo-editing app that lets users edit images stored in a document provider.

好的,所以我在 API 上有一个照片编辑应用程序 运行 16,我可以选择什么来访问(写入)这个文件?每次用户想继续工作时都要求用户导航到图库,这似乎很奇怪,不是吗?同样的道理,在应用程序的私有文件夹中复制似乎不是一个好主意(想想大 pictures/videos...)

在 API19 和引入 ACTION_OPEN_DOCUMENT 之前,没有任何机制可以在重新启动后持久访问 URI - 这正是引入 API 的确切原因。

如果您想允许对同一项目进行多个编辑会话,则必须在自己的存储空间中制作副本space。