2017-12-31 82 views
0

!! 나는이 문제가 전자 메일에 있다는 것을 깨달았습니다. 생각했던대로 작동하지 않습니다. 이메일이 매일 발생하도록 일정을 잡아서 자동으로해야합니다. !! !!전자 메일 데이터베이스가 작동하지 않습니다.

전자 메일로 데이터베이스의 복사본을 보내고 싶습니다. 파일을 SD 카드로 내 보낸 다음 전자 메일로 보내야합니다. 실행하려고하면 "이 응용 프로그램을 수행 할 응용 프로그램이 없습니다"오류가 발생합니다. 나는 SD를 사용할 수있는 안드로이드 에뮬레이터를 사용하고 있습니다.

public void sendEmail(View view){ 

    Intent email = new Intent(Intent.ACTION_SEND); 
    email.putExtra(Intent.EXTRA_SUBJECT, "Daily Records"); 
    email.putExtra(Intent.EXTRA_EMAIL, new String[]{ "[email protected]"}); 
    File sd = Environment.getExternalStorageDirectory(); 
    File data = Environment.getDataDirectory(); 
    FileChannel source=null; 
    FileChannel destination=null; 
    String DB_NAME = "inoutDB.db"; 
    String currentDBPath = "/data/"+ "mypackagename" +"/databases/"+DB_NAME; 
    String backupDBPath = DB_NAME; 
    File currentDB = new File(data, currentDBPath); 
    File backupDB = new File(sd, backupDBPath); 
    try { 
     source = new FileInputStream(currentDB).getChannel(); 
     destination = new FileOutputStream(backupDB).getChannel(); 
     destination.transferFrom(source, 0, source.size()); 
     source.close(); 
     destination.close(); 
     email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(backupDB)); 
    } catch(IOException e) { 
     e.printStackTrace(); 

    } 

    startActivity(Intent.createChooser(email, "Send Email")); 
} 

내가 내 매니페스트

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="15" /> 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
+0

데이터 파일에 액세스 할 수 없습니다. –

+0

데이터 파일에 액세스하려면 어떻게해야합니까? – helpmeplease

+0

이 질문을 관리자에게해야합니다. –

답변

0

문자열 currentDBPath = "/ 데이터 /"+ "mypackagename"의 권한 일부를 추가했습니다 + "/ 데이터베이스 /"+ DB_NAME;

잘못되었습니다. 먼저 경로가 잘못되었습니다 (OEM이 변경할 수는 있지만 일반적으로 앱은/data/data에 설치됩니다). 둘째, 안드로이드에서 경로를 가정해서는 안됩니다. context.getDatabasePath (DB_NAME)를 사용하십시오.