1

I want to share my csv file to any action like Bluetooth, send to email ,etc

 final String filename = Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";



  Intent sharingIntent = new Intent();
                        sharingIntent.setAction(Intent.ACTION_SEND);
                        sharingIntent.putExtra(Intent.EXTRA_STREAM, filename);
                        sharingIntent.setType("text/comma_separated_values/csv");
                        startActivity(Intent.createChooser(sharingIntent, "share file with"));

the output will be no request containt no data

sanoJ
  • 2,935
  • 2
  • 8
  • 18
Allen Oculam
  • 51
  • 1
  • 9

1 Answers1

1

I think that the filename requires a file:// prefix. Android, for sharing any types of file requires a universal identifier or a Uri.

final String fileUriString = "file://" + Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";

Also, change the type to text/csv.

Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse( fileUriString ) ) ;
sharingIntent.setType("text/csv");
startActivity(Intent.createChooser(sharingIntent, "share file with"));

See this answer for more.

Shubham Panchal
  • 4,061
  • 2
  • 11
  • 36