You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Get root Android path, note that is a read-only folder
39
+
-Start `OPEN_DOCUMENT_TREE` activity to prompt user to select an folder to enable write and read access to be used by the `Storage Access Framework` API
39
40
40
41
```dart
41
-
/// Get Android root folder
42
-
final sharedDirectory = await getRootDirectory();
42
+
/// Get permissions to manage an Android directory
43
+
final selectedUriDir = await openDocumentTree();
43
44
44
-
print(sharedDirectory.path); /// `/system`
45
+
print(selectedUriDir);
46
+
```
47
+
48
+
- Create a new file using the `SAF` API
49
+
50
+
```dart
51
+
/// Create a new file using the `SAF` API
52
+
final newDocumentFile = await createDocumentFile(
53
+
mimeType: ' text/plain',
54
+
content: 'My Plain Text Comment Created by shared_storage plugin',
- Get all persisted [URI]s by the `openDocumentTree` API, from `SAF` API
63
+
64
+
```dart
65
+
/// You have [write] and [read] access to all persisted [URI]s
66
+
final listOfPersistedUris = await persistedUriPermissions();
67
+
68
+
print(listOfPersistedUris);
69
+
```
70
+
71
+
- Revoke a current persisted [URI], from `SAF` API
72
+
73
+
```dart
74
+
/// Can be any [URI] returned by the `persistedUriPermissions`
75
+
final uri = ...;
76
+
77
+
/// After calling this, you no longer has access to the [uri]
78
+
await releasePersistableUriPermission(uri);
79
+
```
80
+
81
+
- Convenient method to know if a given [uri] is a persisted `uri` ("persisted uri" means that you have `write` and `read` access to the `uri` even if devices reboot)
82
+
83
+
```dart
84
+
/// Can be any [URI], but the method will only return [true] if the [uri]
85
+
/// is also present in the list returned by `persistedUriPermissions`
86
+
final uri = ...;
87
+
88
+
/// Verify if you have [write] and [read] access to a given [uri]
89
+
final isPersisted = await isPersistedUri(uri);
45
90
```
46
91
47
92
### Android API's
48
93
49
94
Most Flutter plugins uses Android API's under the hood. So this plugin do the same, and to retrieve Android shared folder paths the following API's are being used:
0 commit comments