Android- 如何将字符串数组作为电子邮件正文发送

Android- How to send string array as email body

我需要通过按钮发送一些数据作为电子邮件 click.I 从编辑中成功添加数据 text.But 我不知道如何从我的 database.In 我的代码中发送数据数组需要发送 pn[i] 的值。我添加了像 this.but 这样的值,它在这一行

中导致了错误
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"name:"+edt1.getText().toString()+"\n"+"products:"+pn[i]);

代码:

    btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mydb=buy_ltr.this.openOrCreateDatabase("addcart", MODE_PRIVATE, null);
            Cursor cr = mydb.rawQuery("SELECT * FROM add2cart WHERE usr='"+cont+"'", null);
            String [] pn = new String[cr.getCount()];

            int i = 0;
            while(cr.moveToNext())
            {

                String prp = cr.getString(cr.getColumnIndex("prate"));
                pn[i] = prp;
                i++;
            }


              Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
              String[] recipients = new String[]{"my@email.com", "",};
              emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
              emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
              emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
              emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"name:"+edt1.getText().toString()+"\n"+"address:"+edt2.getText().toString()+"\n"+"products:"+pn[i]);
              emailIntent.setType("text/plain");
    //        emailIntent.setType("message/rfc822");
              startActivity(Intent.createChooser(emailIntent, "Send mail..."));
              finish();

        }
    });

方法一:(内置方法)

String productNames = Arrays.toString(pn);

方法二:(每个产品另起一行)

StringBuilder productNamesBuilder = new StringBuilder();
for(String productName: pn){
    productNamesBuilder.append(productName + "\n");
}
String productNames = productNamesBuilder.toString();

方法三:(编号列表,每个产品换行)

StringBuilder productNamesBuilder = new StringBuilder();
for(int i = 0; i < pn.length; i++){
    productNamesBuilder.append((i + 1) + " " + pn[i] + "\n");
}
String productNames = productNamesBuilder.toString();