Reputation: 271
I have an app which gathers user data, and displays them into a listview. I also have an EmailSender class with the following function;
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {"[email protected]"};
String[] CC = {"[email protected]"};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this,
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
I want to automatically add the sqlite data into the email as an attachment. Any thoughts on that?
Upvotes: 0
Views: 718
Reputation: 401
You can add the sqllite path as an extra like this
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(sqllitePath));
sqlitePath should be built like
sqlitePath = "file://" + sqliteFolder.getAbsolutePath() + "/" + sqliteDbName;
Upvotes: 1