I want to choose only pdf, xlsx and txt file from storage but intent.setType can do only one file(eg.txt file only (or) pdf file only). Is it possible to get all three files
You should use the system function to find the specific mimeType of the file that you are trying to access(Like the "application/pdf"). If you are dealing with any unknown type, it will probably be hard to find the type. Hope this code will save you !
String url=Environment.getExternalStorageDirectory().getAbsolutePath()+"/Saves/contacts.vcf";
File file = new File(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
String mimeType=MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url));
intent.setDataAndType(Uri.fromFile(file), mimeType);
Intent intent1 = Intent.createChooser(intent, "Open With");
startActivity(intent1);
Source HERE