4

My Android Device contains Default File Manager and a Button (Open). How to open the file manager when I click the button?

SeinopSys
  • 8,787
  • 10
  • 62
  • 110
Bala
  • 445
  • 5
  • 11
  • 26

1 Answers1

19

Try something like this in your button listener:

openButton.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_GET_CONTENT);
      intent.setType("file/*");
      startActivity(intent);
   }
}
rfsbraz
  • 2,101
  • 1
  • 18
  • 26
  • 1
    Thanks. It's working for me. But When I select a Button List Out `File Manager` and `OfficeSuite`. How do avoid `OfficeSuite` and then select a Button to View Only `Default File Manager`. Give me any idea.. – Bala Jul 30 '12 at 12:01
  • I'm not sure that is possible or even recommended. A user may not have a default file browser, so I think the best approach is to let the user choose what application he wants to browse files with. Anyway I'll search a bit and let you know if there is other way to do it. – rfsbraz Jul 30 '12 at 12:21
  • 3
    This also showing google drive and extra folders. I want to hide or exclude google drive option . How to achieve it ? – Anand Savjani Aug 28 '15 at 06:43
  • The following code will hide Google Drive: `intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);` – Santosh Rokhade Feb 08 '17 at 14:34
  • Excellent... However, it is showing me the google drive and extra folders as written in above comments.. But, they arent accessible. How can I access them – Shachi Jan 19 '18 at 06:24
  • For me this is opening the Wikipedia app. – Rena Apr 30 '20 at 21:23