Trying to send a SQLite db via email. The email send successfully but there is no attachment with it. My code is :
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);
Try this code, you have to pass your db name and email address on which you want to share db file.
Done