I have written a CSV programmatically, I want to allow the user to be able to open the CSV in an app that they have installed on their device.
I have the following:
File file = new File(Environment.getExternalStorageDirectory(), "My_App_Dir/" + fileName);
Intent csvIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
csvIntent.addCategory(Intent.CATEGORY_OPENABLE);
csvIntent.setDataAndType(FileProvider.getUriForFile(getActivity(), getActivity().getApplicationContext().getPackageName() + ".provider", finalFile), "text/csv");
csvIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
csvIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(csvIntent);
When I run the above code, all I get is the recent files explorer (which doesn't show the file) not the app selection screen to allow the user to select which application they want to use to open the file.
If I go to my devices file explorer app (solid explorer) and select the app, it provides me a list of apps that are capable of supporting the CSV (Google Docs or Excel).