1

I'm using the code below to open a folder created by my application but it's not working, though I got it from Trying open a specific folder in android using intent.

public void openFolder() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String pa = sharedPreferences.getString("path", "");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.parse(pa);
    intent.setDataAndType(uri, "*/*");
    startActivity(Intent.createChooser(intent, "Open folder"));
}

When I am sing Action_View, it shows all possible means except FileManager and in ACTION_GET_CONTENT it took me to SAF mode like to choose storage and then specific folders.

How will it open my defined URI folder directly? Is there any other way?

Micho
  • 3,929
  • 13
  • 37
  • 40
Panache
  • 1,701
  • 3
  • 19
  • 33
  • refer http://stackoverflow.com/questions/17165972/android-how-to-open-a-specific-folder-via-intent-and-show-its-content-in-a-file – sasikumar Dec 22 '16 at 05:25

1 Answers1

0

This should work...

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String file= sharedPreferences.getString("path", "");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(Environment.getExternalStorageDirectory().getPath() + file), "*/*");
startActivity(Intent.createChooser(intent, getString(R.string.open_folder)));
Arpit Patel
  • 1,561
  • 13
  • 23