1
試圖通過電子郵件發送SQLite數據庫。電子郵件發送成功,但沒有附件。我的代碼是:通過電子郵件發送數據庫文件Android
Uri uri;
if(android.os.Build.VERSION.SDK_INT >= 4.2)
{
uri = Uri.fromFile (
new File (
getApplicationContext().getApplicationInfo().dataDir +
"/databases/"+ MainActivity.accounts.getUserName()+ "D"+"/Dentist.db"
)
);
} else {
uri = Uri.fromFile (
new File (
"/data/data/" + getApplicationContext().getPackageName() +
"/databases/"+MainActivity.accounts.getUserName()+ "D"+"/Dentist.db"
)
);
}
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("application/db");
shareIntent.putExtra(Intent.EXTRA_EMAIL,new String[] { "" });
shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Test");
shareIntent.putExtra(Intent.EXTRA_TEXT, "");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(shareIntent);