Get the data from your EditText, Spinner, and DatePicker and store it in a String using the desired delimiter for your csv (e.g., comma, semicolon, tab, space, etc.).
Next save the file and then use Intent.Action_SEND along with Intent.CreateChooser to send the file as an attachment. If your file is stored internally (i.e., it's private) then you also need to use a ContentProvider (see this link).
Here's an example:
//For simplicity's sake let's say you have three methods
//to get the value of your EditText, Spinner,
//and DatePicker and these methods return a String
String editTextValue = getEditTextValue();
String spinnerTextValue = getSpinnerTextValue();
String datePickerTextValue = getDPTextValue();
//Create a String in csv format with the String values obtained
//from the above fictitious methods. The delimiter in this case is the semicolon ";"
String myFileContentString = editTextValue + ";" +
spinnerTextValue + ";" +
datePickerTextValue + "\n";
//Save file to internal storage
FileOutputStream fos = openFileOutput("myfilename.csv", Context.MODE_WORLD_WRITEABLE);
fos.write(myFileContentString.getBytes());
fos.close();
//Send the file as an attachment
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "A CSV File");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "See attachment...");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,
Uri.parse("content://" + MyContentProviderClass.AUTHORITY + "/" + "myfilename.csv"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Don't forget to catch exceptions with try/catch
You will need to subclass a ContentProvider class and override the openFile method. See the links here and here for how to implement your own content provider.
In your ContentProvider subclass, you will want something like the following in the openFile method:
String fileLocation = getContext().getFilesDir() + File.separator + "myfilename.csv";
ParcelFileDescriptor pfd = ParcelFileDescriptor.open(new File(fileLocation),
ParcelFileDescriptor.MODE_READ_ONLY);
return pfd;
And don't forget to update your AndroidManifest.xml with:
<provider android:name="my.package.content.provider.Class"
android:authorities="my.package.content.provider"></provider></application>
The provider declaration in the manifest file goes within the application declaration.