diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index b878c0d01..b7f0cdf4d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -541,7 +541,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View var inputStream: InputStream? = null var out: OutputStream? = null try { - out = getFileOutputStreamSync(destination.absolutePath, source.getMimeType(), getFileDocument(destination.parent)) + val fileDocument = if (isPathOnSD(destination.absolutePath)) getFileDocument(destination.parent) else null + out = getFileOutputStreamSync(destination.absolutePath, source.getMimeType(), fileDocument) inputStream = FileInputStream(source) inputStream.copyTo(out!!) } finally {