| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Plugin to fetch Android shared storage/folders info
This plugin allow us to get path of top-level shared folder (Downloads, DCIM, Videos, Audio) using the following Android API's
/// Get Android [downloads] top-level shared folder
/// You can also create a reference to a custom directory as: `EnvironmentDirectory.custom('Custom Folder')`
final sharedDirectory =
await getExternalStoragePublicDirectory(EnvironmentDirectory.downloads);
print(sharedDirectory.path); /// `/storage/emulated/0/Download`/// Get Android [downloads] shared folder for Android 9+
final sharedDirectory =
await getMediaStoreContentDirectory(MediaStoreCollection.downloads);
print(sharedDirectory.path); /// `/external/downloads`/// Get permissions to manage an Android directory
final selectedUriDir = await openDocumentTree();
print(selectedUriDir);/// Create a new file using the `SAF` API
final newDocumentFile = await createDocumentFile(
mimeType: ' text/plain',
content: 'My Plain Text Comment Created by shared_storage plugin',
displayName: 'CreatedBySharedStorageFlutterPlugin',
directory: anySelectedUriByTheOpenDocumentTreeAPI,
);
print(newDocumentFile);/// You have [write] and [read] access to all persisted [URI]s
final listOfPersistedUris = await persistedUriPermissions();
print(listOfPersistedUris);/// Can be any [URI] returned by the `persistedUriPermissions`
final uri = ...;
/// After calling this, you no longer has access to the [uri]
await releasePersistableUriPermission(uri);/// Can be any [URI], but the method will only return [true] if the [uri]
/// is also present in the list returned by `persistedUriPermissions`
final uri = ...;
/// Verify if you have [write] and [read] access to a given [uri]
final isPersisted = await isPersistedUri(uri);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:
🔗android.os.Environment 🔗android.provider.MediaStore 🔗android.provider.DocumentsProvider
Copyright © 2021-present, Laks Castro.
Shared Storage is MIT licensed 💖
| Back | FazBrowse Home | New Git URL |