diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index b792ca80..b9364534 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -178,6 +178,7 @@ class MainActivity : SimpleActivity() { private fun tryInitFileManager() { handlePermission(PERMISSION_WRITE_STORAGE) { + checkOTGPath() if (it) { initFileManager() } else { @@ -205,6 +206,17 @@ class MainActivity : SimpleActivity() { } } + private fun checkOTGPath() { + Thread { + if (!config.wasOTGHandled && hasPermission(PERMISSION_WRITE_STORAGE) && hasOTGConnected() && config.OTGPath.isEmpty()) { + config.wasOTGHandled = true + getStorageDirectories().firstOrNull { it.trimEnd('/') != internalStoragePath && it.trimEnd('/') != sdCardPath }?.apply { + config.OTGPath = trimEnd('/') + } + } + }.start() + } + private fun openPath(path: String, forceRefresh: Boolean = false) { if (mIsPasswordProtectionPending && !mWasProtectionHandled) { return