SAF(存储访问框架)如何识别您的USB记忆棒? [英] How does SAF (storage access framework) recognize your USB-stick?

查看:137
本文介绍了SAF(存储访问框架)如何识别您的USB记忆棒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Android 6.0.1,API 23

Using Android 6.0.1, API 23,

如何在SAF选择器中看到连接到Android手机的USB棒,以显示所有匹配的文档提供程序(包括USB棒)?此外,如何设置SAF以便在USB便携式存储设备上创建文件和文件夹??

How do you get a USB-stick connected to your Android-phone being visible in the SAF picker that displays all matching document providers (including your USB-stick) ?? Moreover how to set-up SAF in order to create files and folders on the USB portable-storage ??

SAF文档中,我尝试了:

public void performFileSearch() {

    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // in my case, showing only text-files is enough, therefore I guess the type is as follows:
    intent.setType("text/plain");

    startActivityForResult(intent, READ_REQUEST_CODE);
}

但是USB便携式存储不是选择器选择的一部分...

But the USB portable-storage is not part of the picker's choices...

我想念什么?有没有显示必要步骤的示例项目?

What am I missing ? Is there an example project that shows the necessary steps ?

@CommonsWare:这是所需的屏幕截图:

@CommonsWare: Here the desired screenshot:

推荐答案

我刚刚找到了解决该问题的方法:

I just found a solution to the problem:

已启动SAF客户端APP(如在此处找到)-包括我的小改动在performFileSearch()内(即intent.setType("text/plain");而不是原始DevBytesesample intent.setType("image/*");中的内容),解决方案如下:

Having the SAF-client APP started (as found here) - including my tiny change inside performFileSearch() (i.e. intent.setType("text/plain"); instead of what it was in the original DevBytesesample, intent.setType("image/*");, the solution is as follows:

如果您进入设置"(即三个垂直点),则可以选择:"显示内部存储空间"-就是这样!

If you go into "Settings" (i.e. three vertical dots), you can select: "Show internal storage" - and this is it !!

之后,根据需要,SAF的ContentProvider选择器中将显示任何USB记忆棒(请参见下面的屏幕截图)!

After that connecting any USB-stick shows up as desired in the ContentProvider picker of SAF (see screenshot below) !

...不知道为什么外部连接的USB记忆棒会作为内部存储"通过??? (如果有人知道这个谜底的答案,我将不胜感激!)...总之,很高兴终于看到USB闪存出现了!!

...no idea why an exterally connected USB-stick goes through as "internal storage" ??? (if somebody knows an answer to that mystery, I highly appreciate it !)... Anyway, happy to finally see the USB-flash appearing !!

这篇关于SAF(存储访问框架)如何识别您的USB记忆棒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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