将sqlite数据作为电子邮件附件发送

时间:2014-03-10 23:52:54

标签: android sqlite

我有一个收集用户数据的应用程序,并将它们显示在列表视图中。我还有一个具有以下功能的EmailSender类;

 protected void sendEmail() {
  Log.i("Send email", "");

  String[] TO = {"amrood.admin@gmail.com"};
  String[] CC = {"mcmohd@gmail.com"};
  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();
  }
}

我想自动将sqlite数据作为附件添加到电子邮件中。有什么想法?

1 个答案:

答案 0 :(得分:1)

您可以像这样添加sqlite路径

emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(sqllitePath));

sqlite路径应该像

一样构建
sqlitePath = "file://" + sqliteFolder.getAbsolutePath() + "/" + sqliteDbName;
相关问题