How to open file of any format with given storage path

Viewed 3327

I only want to open file from my internal or external storage with given path like /storage/emulated/0/46_1244625499.gif not only image but it can be of any format like .pdf also. I just want to do this on button click event which provide me various open with option to open that file.

I try following:

 Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
 Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+ filename); //filename is string with value 46_1244625499.gif
                intent.setDataAndType(uri, "text/csv");
                startActivity(Intent.createChooser(intent, "Open folder"));

but it don't work.. please provide me working code.

1 Answers

Please make sure that in your device, it has one application at least, that can read your file format. Also, please use this intent: Intent(android.content.Intent.ACTION_VIEW) instead of your intent.

Related