我使用这个代码:发送带有附件的电子邮件,发送一个空白文件
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());
}
但它发送myfile.csv作为一个空白文件。我从文件资源管理器中检查它,其中myfile.csv不是空白并包含正确的数据。我该如何解决这个问题?
我logcat的消息
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 [email protected] (uid=10023 pid=207)
W/IInputConnectionWrapper( 207): showStatusIcon on inactive InputConnection
你可以发布你的logcat – ingsaurabh 2011-02-24 07:34:30