diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java index a31b7b88..fd421eb6 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java @@ -327,6 +327,11 @@ public class FolderActivity extends SyncthingActivity { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); if (externalFilesDirUri != null) { intent.putExtra("android.provider.extra.INITIAL_URI", externalFilesDirUri); + } else { + android.net.Uri internalFilesDirUri = FileUtils.getInternalStorageRootUri(); + if (internalFilesDirUri != null) { + intent.putExtra("android.provider.extra.INITIAL_URI", internalFilesDirUri); + } } intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); intent.putExtra("android.content.extra.SHOW_ADVANCED", true); diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java b/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java index c81b96a3..6b1b7acf 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java @@ -217,6 +217,15 @@ public class FileUtils { return null; } + /** + * FileProvider does not support converting absolute paths + * to a "content://" Uri. As "file://" Uri has been blocked + * since Android 7+, we need to build the Uri manually. + */ + public static android.net.Uri getInternalStorageRootUri() { + return android.net.Uri.parse("content://com.android.externalstorage.documents/document/primary%3A"); + } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) private static String getVolumeIdFromTreeUri(final Uri treeUri) { final String docId = DocumentsContract.getTreeDocumentId(treeUri);