Reputation: 333
i want to open a specific folder by using intent, now its working only when es file manager is available ,i want to open the folder even es file manager is not there, it should work with the inbuilt file manager, what the changes i have to make with my code, any help will be appreciated
here is my code
Button button=(Button)rootview.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/AudioRecords/");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
if (intent.resolveActivityInfo(getActivity().getPackageManager(), 0) != null)
{
startActivity(intent);
}
else
{
// if you reach this place, it means there is no any file
// explorer app installed on your device
}
}
});
Upvotes: 1
Views: 1539
Reputation: 11491
Open folder by using intent, i want to open the folder even file manager is not there
You can't do it in Android API version below 19 (KITKAT) without installed file manager.
public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/myFolder/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
}
Upvotes: 1