Android 6.0 USB大容量存储 [英] Android 6.0 USB Mass Storage

查看:388
本文介绍了Android 6.0 USB大容量存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,Android仅通过Storage Access Framework独家支持USB大容量存储.就我所知,访问数据的唯一方法似乎不是通过典型的方式来装载存储,而是通过Document API和ContentResolver.

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)经过SAF之后,是否不再有简单的File方式来访问存储?

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

2)如果没有,那么如果我们无权访问路径,与NDK中USB存储设备上的文件"进行交互的最佳方法是什么.

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.

推荐答案

DocumentFile的实现存在很多缺陷,主要是因为它与树"和文档" uri以及您<由于工厂中存在大量错误,a href ="https://code.google.com/p/android/issues/detail?id=200941" rel ="nofollow">无法存储树" uri ,而且缺少父级"功能,所以我写了一个有用的名字,巧妙地命名为UsefulDocumentFile

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可以单独使用,但是整个项目都是尝试修补Google用SAF创建的生命周期snafu(如果您请求写许可,则您将中断挂起的写操作以打开严重的HMI的SAF).

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).

这篇关于Android 6.0 USB大容量存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆