简体   繁体   English

在Android中从文件管理器打开文件夹

[英]Opening a folder from file manager in android

I want to open a folder "/sdcard/myApp" after I click on a notification that pops up...what I did is 单击弹出的通知后,我想打开一个文件夹“ / sdcard / myApp” ...我所做的是

Intent notifyIntent=new Intent();
notifyIntent.setAction(Intent.ACTION_GET_CONTENT);
notifyIntent.setType("file/*");

However, this opens /sdcard and not my desired directory...how to handle this?? 但是,这会打开/ sdcard而不是我想要的目录...如何处理?

First, there is no /sdcard on many Android devices. 首先,许多Android设备上都没有/sdcard

Second, having a myApp/ directory in the root of external storage is bad form, and simply will not work on Android 4.2 and higher. 其次,在外部存储的根目录中放置myApp/目录是错误的形式,并且在Android 4.2及更高版本上根本无法使用。 Please use the proper methods on Context (eg, getExternalFilesDir() ) and Environment (eg, getExternalStoragePublicDirectory() ) to find appropriate locations on external storage for use. 请在Context (例如, getExternalFilesDir() )和Environment (例如, getExternalStoragePublicDirectory() )上使用适当的方法,以在外部存储上找到合适的位置以供使用。

Third, file/* is not a valid MIME type AFAIK. 第三, file/*不是有效的MIME类型AFAIK。

Fourth, ACTION_GET_CONTENT is not limited to files, let alone files in a particular directory. 第四, ACTION_GET_CONTENT不限于文件,更不用说特定目录中的文件了。

Fifth, there may be nothing on the user's device capable of browsing files, as "file manager" apps are not part of standard Android and do not have to exist on any given device. 第五,用户设备上可能没有文件可以浏览文件,因为“文件管理器”应用程序不是标准Android的一部分,并且不必存在于任何给定设备上。

If you wish to allow users to browse for a file in a particular directory on external storage, you are welcome to write an activity that does this, or find a library that allows you to add this capability to your project. 如果您希望允许用户浏览外部存储上特定目录中的文件,欢迎编写一个执行此操作的活动,或者查找一个库,该库使您可以将此功能添加到项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM