rkdroid
rkdroid

Reputation: 149

How to open the My Files folder in Android Programatically (using Intent)?

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.

Upvotes: 11

Views: 33750

Answers (6)

Rakshi
Rakshi

Reputation: 6856

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);
        }

Upvotes: 1

varun
varun

Reputation: 497

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.

Upvotes: 2

Aj_31
Aj_31

Reputation: 187

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.

Upvotes: 5

BobroAlexandr
BobroAlexandr

Reputation: 21

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); 

Upvotes: 1

AAnkit
AAnkit

Reputation: 27549

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); 

Upvotes: -1

s.d
s.d

Reputation: 29436

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/

Upvotes: 1

Related Questions