How to open the My Files folder in Android Program

2019-02-03 23:43发布

I am using the below code which opens up the Gallery, Music Player, Dropbox and Contacts, i want the My Files folder to get open programatically, please let me know if there are any specific intent parameters i need to pass to get the File Manager open.

if it is not possible through intent then please give me a snippet or an hint to open the My Files folder programatically.

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
Intent i = Intent.createChooser(intent, "View Default File Manager");
startActivityForResult(i, CHOOSE_FILE_REQUESTCODE); 

Thanks.

6条回答
成全新的幸福
2楼-- · 2019-02-03 23:59

If you want to open samsung My Files application try this below code.

Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");              
intent.putExtra("CONTENT_TYPE", "*/*");
startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE); 
查看更多
beautiful°
3楼-- · 2019-02-04 00:04

You can use this code to file the files.

int PICKFILE_RESULT_CODE=1;            
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);                 
intent.setType("file/*");              
startActivityForResult(intent,PICKFILE_RESULT_CODE);

this will help you to browse the files from your storage.

查看更多
一纸荒年 Trace。
4楼-- · 2019-02-04 00:06

Its best that you include a library in your project which handles this scenario.

This worked for me:

This library shows the list of third-party apps. It also has its own file browser for selecting files.

查看更多
做自己的国王
5楼-- · 2019-02-04 00:06

You have to specifically mention the package name of the explorer application. Please find the example below to open a specific folder in ES Explorer.

 public void openfolderInexplorer(String path){
  Intent intent = this.getPackageManager().getLaunchIntentForPackage("com.estrongs.android.pop");
 if (intent != null) {
           // If the application is avilable
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Uri uri = Uri.parse(path);
            intent.setDataAndType(uri, "resource/folder");
            this.startActivity(intent);
        } else {
            // Play store to install app
            intent = new Intent(Intent.ACTION_VIEW);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setData(Uri.parse("market://details?id=" + 
            "com.estrongs.android.pop"));
            this.startActivity(intent);
        }
查看更多
Melony?
6楼-- · 2019-02-04 00:13

try this below code. if any file manager available , then it will pop up in a form of menu to choose appropriate for the user.

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE); 
查看更多
Animai°情兽
7楼-- · 2019-02-04 00:14

Bad thing is, most Android distributions may or may not ship with a file manager, and even so, may be not with the one which handles CHOOSE_FILE_REQUESTCODE.

So, you are left to create your own file picker activity. Luckily there are many ready made ones available:

http://code.google.com/p/android-filechooser/

https://developers.inkfilepicker.com/docs/android/

查看更多
登录 后发表回答