android中如何选择文件夹?
您好,有一种方法可以选择用户想要在 android 中保存文件的文件夹。我查看 http://code.google.com/p/android-file-dialog /
它具有选择文件的功能,但我想选择文件夹,请为我提供可用的链接或示例。
Hi there is a way to select folder where user want to save file in android . I check out http://code.google.com/p/android-file-dialog/
it has functionality to select file but i want to select folder , please provide me usable link or examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用OI 文件管理器怎么样?该应用程序具有以下意图:
PICK_FILE
、PICK_DIRECTORY
。页面上甚至还有使用意图的示例代码。
How about using OI File Manager? This App has the following Intents:
PICK_FILE
,PICK_DIRECTORY
.There is even sample code on the page for using the Intents.
我在我的应用程序中使用了相同的源(非常确定),并且有一个代码块:
您只需编辑它处理
if (file.isDirectory())
的方式。我建议在您的 Activity 中声明一个boolean
值,如果文件是一个目录并且它已经是 false,则将其更改为true
。然后如果该值为true,则遍历该目录。此外,当您将所述值更改为true
时,您需要调用selectButton.setEnabled(true)
。我想说,这比编写自己的代码要简单得多。I used the same source in my app (pretty sure), and there is a block of code:
You just have to edit how it handle's
if (file.isDirectory())
. I would recommend declaring aboolean
value in your Activity which you change totrue
if the file is a directory and it is already false. Then if said value is true, then traverse the directory. Also when you change said value totrue
, you would need to callselectButton.setEnabled(true)
. This would be quite a bit less complicated than making your own code, I would say.查看此答案https://stackoverflow.com/a/28479561/779140
我被提到是图书馆作者,所以请随时提出任何问题。
Check out this answer https://stackoverflow.com/a/28479561/779140
I am mentioned library author so don't hesitate to ask any questions.
我遇到了同样的问题,最终使用 NoNonsense-FilePicker
添加到gradle文件
触发文件/文件夹/目录选择
处理活动结果以获取选定的文件或文件
I encountered the same issue and I end up using NoNonsense-FilePicker
Add to gradle file
Trigger file/folder/dir pick
Handle Activity result to get selected file or files