Sending Email with attachment, sends a blank file
<p>I am using this code: </p>

<pre><code>File myDir = new File(getApplicationContext().getFilesDir().getAbsolutePath());
try {                
    Log.i("CSV Testing ", "CSV file creating");
    FileWriter fw = new FileWriter(myDir + "/myfile.csv");
    //
                 // write data to file
                 //   
    Log.i("CSV Testing ", "CSV file created and your data has been saved");
    // Process for sending email with CSV file
    File CSVFile = new File(myDir,"myfile.csv");
    // And sending it with email attachment
} catch (IOException e) {
    Log.i("ExportCSV Exception", e.toString());
}
</code></pre>

<p>But it sends myfile.csv as a blank file. I checked it from file explorer, where myfile.csv is not blank and contains right data. How can I solve this?</p>

<p>My Logcat messages are </p>

<pre><code>I/CSV Testing (16920): CSV file creating
I/CSV Testing (16920): CSV file created and your data has been saved
I/CSV FILE(16920): CSV file exists
I/SEND EMAIL TESTING(16920): Email sending
D/dalvikvm(16920): GC freed 2902 objects / 186576 bytes in 156ms
I/ActivityManager(   60): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
W/ActivityManager(   60): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.CHOOSER flg=0x800000 cmp=android/com.android.internal.app.ChooserActivity (has extras) }
I/ActivityManager(   60): Displayed activity com.android.email/.activity.MessageCompose: 1156 ms (total 2117 ms)
W/InputManagerService(   60): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@43cf3050 (uid=10023 pid=207)
W/IInputConnectionWrapper(  207): showStatusIcon on inactive InputConnection
</code></pre>
