Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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.
Posted
Comments
F-ES Sitecore 10-Dec-15 9:19am    
Have you at least done basic research? I googled "send email in android app" and found loads of examples of how to send email. You can put the data in the body, or if you want to send as an attachment googled "create file android" and "send email with attachment android". All you have to do is put these techniques together. When you ask a question that involves doing multiple things, and each of those things is easily solved from google your question comes across as simply a request for someone else to do your work.
Arindam Tewary 10-Dec-15 9:26am    
Do you want content of the textview in a file, then sent that file to some email address ?

You can save your textview data to a text file by this code example:
C#
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:
Java
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.
 
Share this answer
 
v3
Comments
Member 12198701 11-Dec-15 0:55am    
@ridoy much appreciated. Thank you
ridoy 11-Dec-15 12:25pm    
welcome.
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900