안녕하세요~

 

이메일로 텍스트 파일을 첨부해서 보냈는데요..

 

텍스트 파일은 /data/local/output.txt 여기에 있습니다..

 

파일도 첨부가 된 것 같은데.. 막상 보내진 이메일을 확인 해 보면 첨부 파일이 없습니다....

 

output.txt 는 저의 프로그램 안에서 생성이 되어 /data/local/ 디렉토리에 들어 가게 되요..

 

이 파일을 메일을 통해 보내고 싶은데... ㅠ_ㅜ

 

왜 확인해 보면 첨부 파일이 없는 걸까요? ㅠ_ㅜ 어디에서 에러가 난건지..알려 주세요!

 

만약 이메일 보낼때 /data/local 에서 파일을 읽어 올 수 없는 경우

 

output.txt 를 어디다가 생성 해서 보낼 수 있을 까요 ?ㅠ_ㅜ

 

/mnt/sdcard 여기다가 넣으려고 햇는데 read-only 파일 이라고 해서 써지지를 안아요....

 

감사합니다!@@@

 

아래는 메일 보내는 부분인 저의 코드 입니다.....-----------------------------------------------------------------------------------------

 

package com.android.tcpdump.sendemail;

import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class SendFileExActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  // 버튼 객체
  Button btEmail = (Button) findViewById(R.id.btEmail);
  String szSendFilePath = Environment.getDataDirectory()
    .getAbsolutePath() + "/local/output.txt";
  File f = new File(szSendFilePath);
  if (!f.exists()) {
   Toast.makeText(this, "파일이 없습니다.", Toast.LENGTH_SHORT).show();
  }

  // File객체로부터 Uri값 생성
  final Uri fileUri = Uri.fromFile(f);
  

  /** 첨부파일 이메일 보내기 */
  btEmail.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    Intent it = new Intent(Intent.ACTION_SEND);
    
    it.setType("plain/text");
    /*
     * String[] tos = { "" }; it.putExtra(Intent.EXTRA_EMAIL, tos);
     *
     * it.putExtra(Intent.EXTRA_SUBJECT, "제목");
     * it.putExtra(Intent.EXTRA_TEXT, "내용");
     */
    // 파일첨부
    it.putExtra(Intent.EXTRA_STREAM, fileUri);

    startActivity(it);
   }
  });
 }
}