Android 6.0 USB Mass Storage

限于喜欢 提交于 2020-01-03 03:03:17

问题


USB mass storage is now officially supported by Android, exclusively through the Storage Access Framework. It does not seem to mount the storage in a typical sense, as far as I can tell the only way to access the data is through the Document API and ContentResolver.

1) Is there no longer a simple File way to access the storage after going through the SAF?

2) If not, what's the best way to interact with 'files' on USB storage in NDK if we don't have access to paths.


回答1:


There are a lot of flaws in the implementation of DocumentFile, primarily as it relates to "tree" vs "document" uris and the fact that you cannot store a "tree" uri due to a huge bug in the factory, but also in the lack of 'parent' functionality, so I wrote a useful one, cleverly named UsefulDocumentFile

https://github.com/rcketscientist/DocumentActivity/blob/master/library/src/main/java/com/anthonymandra/framework/UsefulDocumentFile.java

UsefulDocumentFile can stand on it's own, but the overall project is an attempt to patch the life-cycle snafu Google created with SAF (If you request write permission you interrupt the pending write action to open SAF which is awful HMI).



来源:https://stackoverflow.com/questions/34693645/android-6-0-usb-mass-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!