How to access different File Manager specific path

2020-07-17 15:20发布

I have installed different types of File Manager. The different Types of File Managers are

  1. Default File Manager
  2. ASTRO-File-Manager-v3.1.342.apk(Astro)
  3. FileManager-1.2.apk(OI File Manager)
  4. Root-Browser-File-Manager-v1.4.0.apk(Root Browser)

Code :

File filePath = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Pictures");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setDataAndType(Uri.parse("file:/"+filePath.getAbsolutePath()), "file/*");
startActivityForResult(intent,PICKFILE_RESULT_CODE);

When I can select Astro File Manager, Root Browser, Default File Manager I got the location path as /mnt/sdcard.

But when I access the OI File Manager I got the location path as /mnt/sdcard/Pictures.

How do get and open to different types of File Manager to access the location path as /mnt/sdcard/Pictures

1条回答
老娘就宠你
2楼-- · 2020-07-17 15:39

Specifying initial path to a file explorer? You can't.

Read documentation for ACTION_GET_CONTENT. The contract for using this action doesn't specify initial location at all. So various file managers do different things, and it's all legal and correct. Some use the data you try to input, some use last directory where user was, some start at root of sdcard.

Btw, your mime type "file/*" looks like nonsense, there's no such known mime type. Just use "*/*" to match all files.

查看更多
登录 后发表回答