When sharing an image with Intent.createChooser my file disappears!

private void share() {

    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/png");

    share.putExtra(Intent.EXTRA_STREAM,
      Uri.parse("file://" + filename));

    startActivity(Intent.createChooser(share, "Share Tag"));

}

I implemented this simple function for calling from the menu, but after I name it, the file that I shared will completely disappear - it is as if part of it is deleting it from my repository. Why is this done, and how can I stop it?

+3
source share
1 answer

Try to do this instead:

Uri uri = Uri.fromFile(new File(filename));
share.putExtra(Intent.EXTRA_STREAM, uri);
+5
source

All Articles