StoragePaths
Provides access to commonly used storage paths on the device.
**Platform Limitation:** Methods are not supported in web mode.
Inherits: Service
Methods
get_application_cache_directory()** asyncstr - Path to application-specific cache directory. Created if it doesn't exist.
* Raises: FletUnsupportedPlatformException on web.get_application_documents_directory()** asyncstr - Path to directory for user-generated data (non-recreatable).
* Raises: FletUnsupportedPlatformException on web.get_application_support_directory()** asyncstr - Path to directory for application support files (not user-visible, not for user data). Created if it doesn't exist.
* Raises: FletUnsupportedPlatformException on web.get_console_log_filename()** asyncstr - Path to console.log file for debugging (located in app cache directory).
* Raises: FletUnsupportedPlatformException on web.get_downloads_directory()** asyncstr | None - Path to the downloads directory. May not exist; client must verify/create.
* Raises: FletUnsupportedPlatformException on web.get_external_cache_directories()** asynclist[str] | None - List of paths to external cache directories (e.g., SD cards). Available on Android.
* Raises: FletUnsupportedPlatformException on web or non-Android.get_external_storage_directories()** asynclist[str] | None - List of paths to external storage directories (e.g., SD cards). Available on Android.
* Raises: FletUnsupportedPlatformException on web or non-Android.get_external_storage_directory()** asyncstr | None - Path to the top-level external storage directory. Available on Android.
* Raises: FletUnsupportedPlatformException on web or non-Android.get_library_directory()** asyncstr - Path to the library directory (persistent, backed-up files not visible to user, e.g., sqlite.db). Available on non-Apple platforms.
* Raises: FletUnsupportedPlatformException on web or Apple platforms.get_temporary_directory()** asyncstr - Path to the temporary directory (not backed up, suitable for caches, files may be cleared).
* Raises: FletUnsupportedPlatformException on web.Examples
Basic Example
import flet as ftasync def main(page: ft.Page):
storage_paths = ft.StoragePaths()
items = []
for label, method in [
("Application cache directory", storage_paths.get_application_cache_directory),
("Application documents directory", storage_paths.get_application_documents_directory),
("Application support directory", storage_paths.get_application_support_directory),
("Downloads directory", storage_paths.get_downloads_directory),
("External cache directories", storage_paths.get_external_cache_directories),
("External storage directories", storage_paths.get_external_storage_directories),
("Library directory", storage_paths.get_library_directory),
("External storage directory", storage_paths.get_external_storage_directory),
("Temporary directory", storage_paths.get_temporary_directory),
("Console log filename", storage_paths.get_console_log_filename),
]:
try:
value = await method()
except ft.FletUnsupportedPlatformException as e:
value = f"Not supported: {e}"
except Exception as e:
value = f"Error: {e}"
else:
if isinstance(value, list):
value = ", ".join(value)
elif value is None:
value = "Unavailable"
items.append(
ft.Text(
spans=[
ft.TextSpan(f"{label}: ", style=ft.TextStyle(weight=ft.FontWeight.BOLD)),
ft.TextSpan(value),
]
)
)
page.add(ft.Column(items, spacing=5))
ft.run(main)