Question

Hello I'm trying to share a file, but when uploading to DropBox or GoogleDrive etc. .. I get a message that the file is not found. Thanks for the help

invia.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        shareIt();
        }

        private Intent shareIt() {

            Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setType("*/*");
            shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            Uri uri = Uri.parse("/data/data/"+getPackageName()+"/databases/Mydb.db");
            shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
            startActivity(Intent.createChooser(shareIntent, "Share via"));
            return shareIntent;
        }
     });
}
Was it helpful?

Solution

The receiving application needs permission to access the data the Uri points to. There are two recommended ways from the Android Developer Site :Send Binary Content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top