如何将Textview数据保存到Android中的文本文件和电子邮件中。 [英] How Do I Save Textview Data Into A Text File And Email In Android.

查看:207
本文介绍了如何将Textview数据保存到Android中的文本文件和电子邮件中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好吧



我正在写一个关于完整的Android应用程序,除了我遇到的一个小问题。当用户在计算后得到他们的结果时,金额会显示在TextViews中,我需要帮助的问题是将这些值保存在文本文件中,而不是通过电子邮件发送给相应的人。这一切都应该通过单击按钮来完成。

Hi all

I am writing an android app which is about complete except for a small problem i have run into. When a user gets their results after a calculation, the amounts are displayed into TextViews, my problem which i need help in is getting those values saved in a text file and than emailed to the respective person. This should all be done with the click of a button.

推荐答案

您可以通过以下代码示例将textview数据保存到文本文件:

You can save your textview data to a text file by this code example:
File root = new File(YOUR_DIRECTORY_PATH);
  File gpxfile = new File(root, "yourFileName.txt");
  FileWriter writer = new FileWriter(gpxfile);
  writer.append(yourTextview.getText().toString());
  writer.flush();
  writer.close();





要将文件作为电子邮件附件发送,您可以尝试:



To send the file as email attachment you can try:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(YOUR_FILE_PATH));
sendIntent.setType("text/plain");
startActivity(sendIntent);





您可以为这两项任务制作两种不同的方法,并在按钮点击事件中使用它们,就是这样。



You can make 2 separate methods for these 2 tasks and use them in your button click event, that's all.


这可以分两步完成。

首先你需要将内容保存在一个文件中

保存在文本文件中



一旦保存,您需要发送到一个电子邮件地址

< a href =http://stackoverflow.com/questions/30016888/send-text-file-attachment-with-an-email>发送文件附件

发送文件,另一个例子



检查以上链接,你可以这样做。尝试检查learn2crack网站,那里的例子非常好。



让我知道是否有帮助。
This could be accomplished in two step.
First you need to save content in a file
Save in Text file

Once you save, you need to sent to a email address
send file attachement
Sent to file, another example

Check above links, you could do that. Try checking learn2crack site, examples are really good there.

let me know if tat helps.


这篇关于如何将Textview数据保存到Android中的文本文件和电子邮件中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆