Спасибо всем, кто пытался помочь. После целого дня я отправил электронное письмо из моего приложения с приложением. Это рабочий код.
String columnString = "\"PersonName\",\"Gender\",\"Street1\",\"postOffice\",\"Age\"";
String dataString = "\"" + currentUser.userName +"\",\"" + currentUser.gender + "\",\"" + currentUser.street1 + "\",\"" + currentUser.postOFfice.toString()+ "\",\"" + currentUser.age.toString() + "\"";
String combinedString = columnString + "\n" + dataString;
File file = null;
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
File dir = new File (root.getAbsolutePath() + "/PersonData");
dir.mkdirs();
file = new File(dir, "Data.csv");
FileOutputStream out = null;
try {
out = new FileOutputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
out.write(combinedString.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Uri u1 = null;
u1 = Uri.fromFile(file);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Person Details");
sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
sendIntent.setType("text/html");
startActivity(sendIntent);
Также, если вы установилиВаш телефон SDCard в машине, этот код не будет работать.Только один может получить доступ к SDCard одновременно.Поэтому в этом случае отключите SDCard от компьютера и попробуйте .. Спасибо парню, который ответил здесь .. Также убедитесь, что вы купили разрешение на запись во внешнее хранилище в файле манифеста ...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
Надеюсь, это кому-нибудь поможет ... Спасибо всем, кто пытался помочь ..