I have two apps, one is writing the file and other one (Gmail) is trying to attach that file. But now, the Gmail app gives the error of
Permission denied for attaching the file.
I think I am storing the file in private directory that is /data/data/PACKAGE/files/file.txt
Where can i write the file so that Gmail app not give the error?
I am attaching the file as;
String filelocation = "/data/data/com.example.xxxxxxxxx/files/file.txt";
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain");
String message="File to be shared is " + file_name + ".";
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse( "file://"+filelocation));
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.setData(Uri.parse("mailto:xyz@gmail.com"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);