1---2name: android-media-files-sharing3description: Use modern Android file, media, picker, FileProvider, and share-sheet APIs with minimal permissions.4---5# Android Media Files Sharing67## When To Use8- Use this skill when the request is about: android file sharing, photo picker android app, fileprovider setup android.9- Primary outcome: Use modern Android file, media, picker, FileProvider, and share-sheet APIs with minimal permissions.10- Reach for this skill when the core problem is content URIs, share-sheet flows, picker choice, or app-to-app file exchange. Use `android-permissions-activity-results` only when the hard part is the runtime permission flow itself.11- Handoff skills when the scope expands:12- `android-permissions-activity-results`13- `android-security-best-practices`1415## Workflow161. Start with the asset movement path: pick existing media, open a document, create/export a file, capture new content, or share app-owned content to another app.172. Choose the narrowest platform surface first: Photo Picker, SAF contracts, `FileProvider`, or chooser-based sharing before considering broad storage permissions.183. Keep file ownership and URI grants explicit with app-private storage, MIME types, temporary grants, and stable authorities.194. Validate return flows, absent-capability fallbacks, and recipient-app interoperability instead of testing only the happy path.205. Hand off runtime permission complexity or deeper hardening only after the URI and sharing contract is correct.2122## Guardrails23- Prefer Photo Picker, SAF, and chooser APIs over broad media or storage permissions where possible.24- Share content with `content://` URIs and temporary grants, never raw file paths.25- Keep exported authorities, MIME types, and cache cleanup explicit.26- Treat recipients outside your app as untrusted; validate what leaves the app and what comes back.2728## Anti-Patterns29- Requesting broad media or storage access when Photo Picker or SAF is enough.30- Sharing `file://` paths or world-readable files instead of `FileProvider` URIs.31- Assuming every recipient app handles every MIME type or URI permission correctly.32- Mixing permission-flow design with file-sharing contract design until both become unclear.3334## Review Focus35- Picker/SAF/FileProvider/chooser selection.36- MIME type, URI authority, and grant lifecycle correctness.37- Minimal-permission media access.38- Recipient-app interoperability and cleanup of temporary files.3940## Examples41### Happy path42- Scenario: Attach and share a task snapshot using the least-privilege API.43- Command: `cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest`4445### Edge case46- Scenario: Handle absent picker support or denied media capabilities in the XML fixture.47- Command: `cd examples/orbittasks-xml && ./gradlew :app:testDebugUnitTest`4849### Failure recovery50- Scenario: Separate media/file flows from permission-only or networking-only requests.51- Command: `python3 scripts/eval_triggers.py --skill android-media-files-sharing`5253## Done Checklist54- The platform surface is narrower than a broad storage permission where possible.55- URI authorities, MIME types, and temporary grants are explicit.56- Picker and share-sheet fallbacks are covered.57- Permission-only work is handed off instead of conflated with the sharing contract.5859## Official References60- [https://developer.android.com/training/data-storage/shared/photopicker](https://developer.android.com/training/data-storage/shared/photopicker)61- [https://developer.android.com/training/data-storage/shared/documents-files](https://developer.android.com/training/data-storage/shared/documents-files)62- [https://developer.android.com/training/secure-file-sharing/setup-sharing](https://developer.android.com/training/secure-file-sharing/setup-sharing)63- [https://developer.android.com/training/sharing/send](https://developer.android.com/training/sharing/send)64- [https://developer.android.com/topic/performance/graphics/picker](https://developer.android.com/topic/performance/graphics/picker)