无法附加文件-Android

时间:2018-08-15 23:20:52

标签: android email attachment

我想通过电子邮件发送SQLite数据库。我将数据库文件导出到外部存储。当我单击发送按钮时,Gmail UI会打开,并显示一条消息“无法附加文件”。我该如何解决?

final ImageButton syncbutton = findViewById(R.id.syncbtn);
    syncbutton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            exportToSD();
            String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());

            PACKAGE_NAME = getApplicationContext().getPackageName();
            File Root= Environment.getExternalStorageDirectory();
            String filelocation=Root.getAbsolutePath() +"/ODB.db";
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setPackage("com.google.android.gm");
            intent.putExtra(Intent.EXTRA_EMAIL, "info@blabla.com");
            intent.putExtra(Intent.EXTRA_SUBJECT, mydate);
            intent.putExtra(Intent.EXTRA_TEXT, "Lorem Ipsum");
            Uri attachments = Uri.parse(filelocation);
            intent.setData(attachments);
            intent.putExtra(Intent.EXTRA_STREAM, attachments);
            intent.setType("message/rfc822");
            startActivity(intent);

        }
    });

0 个答案:

没有答案