File created using MODE_WORLD_READABLE not getting sent as attachment by email

Posted by Dheeraj on Stack Overflow See other posts from Stack Overflow or by Dheeraj
Published on 2012-06-21T09:03:32Z Indexed on 2012/06/21 9:16 UTC
Read the original article Hit count: 204

Filed under:
|

I created the SQLite DB using the following code:

context.openOrCreateDatabase(dbName, Context.MODE_WORLD_READABLE, null);

And tried to send it as attachment by email using the following code:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND)
        .setType("message/rfc822")
        .putExtra(android.content.Intent.EXTRA_STREAM,
                Uri.fromFile(getDatabasePath(dbName)));
startActivity(Intent.createChooser(emailIntent, null));

This opens the GMail compose activity with the attachment icon. But the recipient did not receive the attachment.

This has been asked before. But it looks like there is no solution other than to copy the db file to SD card.

My question then is: What is the use of the MODE_WORLD_READABLE flag if another app like GMail is unable to read the file?

© Stack Overflow or respective owner

Related posts about android

Related posts about email-attachments