mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Android: Add method to take persistable URI permission
This commit is contained in:
@@ -790,8 +790,17 @@
|
||||
[b]Note:[/b] On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use [method OS.get_granted_permissions] to get a list of saved bookmarks.
|
||||
[b]Note:[/b] On Android, this method uses the Android Storage Access Framework (SAF).
|
||||
The file picker returns a URI instead of a filesystem path. This URI can be passed directly to [FileAccess] to perform read/write operations.
|
||||
When using [constant FILE_DIALOG_MODE_OPEN_DIR], it returns a tree URI that grants full access to the selected directory. File operations inside this directory can be performed by passing a path in the form [code]treeUri#relative/path/to/file[/code] to [FileAccess].
|
||||
Tree URIs should be saved and reused; they remain valid across app restarts as long as the directory is not moved, renamed, or deleted.
|
||||
When using [constant FILE_DIALOG_MODE_OPEN_DIR], it returns a tree URI that grants full access to the selected directory. File operations inside this directory can be performed by passing a path on the form [code]treeUri#relative/path/to/file[/code] to [FileAccess].
|
||||
To avoid opening the file picker again after each app restart, you can take persistable URI permission as follows:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
val uri = "content://com.android..." # URI of the selected file or folder.
|
||||
val persist = true # Set to false to release the persistable permission.
|
||||
var android_runtime = Engine.get_singleton("AndroidRuntime")
|
||||
android_runtime.updatePersistableUriPermission(uri, persist)
|
||||
[/gdscript]
|
||||
[/codeblocks]
|
||||
The persistable URI permission remains valid across app restarts as long as the directory is not moved, renamed, or deleted.
|
||||
</description>
|
||||
</method>
|
||||
<method name="file_dialog_with_options_show">
|
||||
|
||||
Reference in New Issue
Block a user