- if (!mOriginalStoragePath.equals(temporalPath)) { // preventing
- // weird
- // but
- // possible
- // situation
- InputStream in = null;
- OutputStream out = null;
- try {
- File temporalParent = temporalFile.getParentFile();
- temporalParent.mkdirs();
- if (!temporalParent.isDirectory()) {
- throw new IOException("Unexpected error: parent directory could not be created");
- }
- temporalFile.createNewFile();
- if (!temporalFile.isFile()) {
- throw new IOException("Unexpected error: target file could not be created");
- }
- in = new FileInputStream(originalFile);
+
+ File temporalParent = temporalFile.getParentFile();
+ temporalParent.mkdirs();
+ if (!temporalParent.isDirectory()) {
+ throw new IOException("Unexpected error: parent directory could not be created");
+ }
+ temporalFile.createNewFile();
+ if (!temporalFile.isFile()) {
+ throw new IOException("Unexpected error: target file could not be created");
+ }
+
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+
+ // In case document provider schema as 'content://'
+ if (mOriginalStoragePath.startsWith(UriUtils.URI_CONTENT_SCHEME)) {
+
+ Uri uri = Uri.parse(mOriginalStoragePath);
+
+ in = MainApp.getAppContext().getContentResolver().openInputStream(uri);