Skip to content

Instantly share code, notes, and snippets.

@CapTen101
Last active February 19, 2021 19:22
Show Gist options
  • Select an option

  • Save CapTen101/36d5465f51e570a25e9dcd01ee289933 to your computer and use it in GitHub Desktop.

Select an option

Save CapTen101/36d5465f51e570a25e9dcd01ee289933 to your computer and use it in GitHub Desktop.
inputStream.close();
outputStream.close();
Uri copyImage = Uri.fromFile(copyImageFile);
String nameOfFile = "copyImageFile.jpg"
File copyImageFile = new File(getCacheDir(), nameOfFile);
ParcelFileDescriptor parcelfileDescriptor = this.getContentResolver().openFileDescriptor(selectedImage, "r");
FileDescriptor fileDescriptor = parcelfileDescriptor.getFileDescriptor();
FileInputStream inputStream = new FileInputStream(fileDescriptor);
FileChannel inputStreamChannel = inputStream.getChannel();
FileOutputStream outputStream = new FileOutputStream(copyImageFile);
FileChannel outputStreamChannel = outputStream.getChannel();
inputStreamChannel.transferTo(0, inputStreamChannel.size(), outputStreamChannel);
@CapTen101
Copy link
Author

Created OpenThroughParcelFileDescriptor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment