# android_file_picker 2.1.2

Android implementation of the file_picker plugin, supporting file picking, saving, and Storage Access Framework (SAF) URI grants.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add android_file_picker
```
Published: 2026-10-25T16:20:19.182636Z
Expected archive SHA-256: 03d3dd3cb578ab26b1e528aeea27bf6b976942f5a24e3da82d270369b8e161a8

Available in cache; verification: upstream_checksum
## Direct dependencies
- cross_file: ^0.3.5+4
- file_picker_platform_interface: ^4.0.0
- flutter: map[sdk:flutter]
- path: ^1.9.0

## Package README (untrusted upstream documentation)
![File Picker for Android](https://raw.githubusercontent.com/vicajilau/flutter_file_picker/main/.github/assets/readme_banner_android.svg)

# android_file_picker

The Android implementation of `file_picker`.

## Usage

This package is endorsed, which means you can simply use `file_picker` as normal, and the Android implementation will be automatically included.

## Android setup

If your app overrides `onActivityResult` in a custom `MainActivity`, make sure it calls `super.onActivityResult(...)` for activities it doesn't handle itself. Otherwise the plugin's own `onActivityResult` (in `FilePickerDelegate`) never runs, and picking a file fails silently.

### `initialDirectory` is not supported for picking

`initialDirectory` currently has no effect on `pickFile()`, `pickFiles()`, `pickFileAndDirectoryPaths()`, or `getDirectoryPath()` on Android. The native side launches `ACTION_OPEN_DOCUMENT`, `ACTION_OPEN_DOCUMENT_TREE`, and `ACTION_GET_CONTENT` intents, none of which are given a starting location. It only works for `saveFile()` today.

Supporting it for picking would need turning a plain file path into a `content://` document tree URI for `DocumentsContract.EXTRA_INITIAL_URI`, which Android's Storage Access Framework does not map to directly, so this is tracked as a future improvement rather than a quick fix.

## Changelog
## 2.1.2

- Fixed `explorer_not_found` on Android 11+ devices that hide the documents picker from apps, such as some Xiaomi HyperOS versions. [#2282](https://github.com/vicajilau/flutter_file_picker/pull/2282)
- The picker now opens directly and only reports `explorer_not_found` when no app can handle it, instead of asking Android first, which can miss apps hidden from the plugin.

## 2.1.1

- Fixed `AndroidSAFOptions` being ignored, so the grant, access mode and persistence they request now apply. [#2257](https://github.com/vicajilau/flutter_file_picker/issues/2257)
- Picking several files now fails with `unknown_path` when none of them can be read, instead of returning an empty list as if the user cancelled. [#2262](https://github.com/vicajilau/flutter_file_picker/issues/2262)

## 2.1.0

- Added `FilePickerAndroid.retrieveLostData()`, to recover the files picked when Android destroys the activity while the picker is open. [#1258](https://github.com/vicajilau/flutter_file_picker/issues/1258)

## 2.0.1

- Fixed `pickFileAndDirectoryPaths()` returning percent-encoded paths that do not exist. [#2225](https://github.com/vicajilau/flutter_file_picker/issues/2225)

## 2.0.0

- **BREAKING CHANGE**: `PlatformFile.length()` now returns `Future<int?>` instead of `Future<int>`. Returns `null` when the length could not be determined (e.g. a failed disk read), instead of `0`, matching `lengthSync()`. [#2197](https://github.com/vicajilau/flutter_file_picker/issues/2197)
- Removed the native code paths behind `withData`, dead since the Dart facade stopped forwarding it (`file_picker` 12.0.0). Picked files are no longer eagerly read into memory on the platform side; `PlatformFile.readAsBytes()` already reads lazily on demand. [#2202](https://github.com/vicajilau/flutter_file_picker/issues/2202)

## 1.1.1

- Fixed `saveFile()` garbling the file name for extensions Android doesn't recognize, e.g. saving `trace.gpx` produced `trace.gpx.xml.gpx`. [#2199](https://github.com/vicajilau/flutter_file_picker/issues/2199)

## 1.1.0

- Implemented `PlatformFile.lengthSync()`, returning the length Android already reports for a picked file synchronously.

## 1.0.4

- Restored the module local `buildscript` classpath (AGP 8.5.2, Kotlin Gradle Plugin 1.8.22) that #2154 removed. It fixed `Unresolved reference compileSdk/namespace/minSdk` on project configurations using AGP 9 with `android.newDsl=false` and custom root level Gradle configuration, reported and confirmed fixed against a real affected project in [#2170](https://github.com/vicajilau/flutter_file_picker/issues/2170).

  This is a temporary workaround, not a permanent fix. Pinning an older AGP via a module's own `buildscript` classpath while the consuming app applies a newer one through the `plugins` block is generally discouraged, and #2154 removed it for exactly that reason. Restoring it papers over a gap in Flutter's own AGP 9 `newDsl` migration, which is still in progress ([flutter/flutter#180137](https://github.com/flutter/flutter/issues/180137)): the interim compatibility shim that lets `android.newDsl=false` projects use AGP 9 does not appear to reliably reach plugin modules that don't declare their own classpath, at least for some custom root level Gradle setups. Remove this block again once that migration lands upstream and `android.newDsl=false` is no longer needed.

## 1.0.3

- Tightened the `file_picker_platform_interface` lower bound to `^3.2.0`. This package's `pickFile()`/`pickFiles()` signatures reference `DarwinOptions`, added in that version, so resolving against an older one would fail to compile.

## 1.0.2

- Removed the stale `buildscript` classpath from the Android module, which pinned AGP 8.5.2 and Kotlin Gradle Plugin 1.8.22 in a module that supports AGP 9 and Kotlin 2.3. [#2154](https://github.com/vicajilau/flutter_file_picker/pull/2154)
- Fixed `allowedExtensions` filters being discarded entirely and falling back to showing all files when only some of the requested extensions had no mime type known to Android (e.g. `pfx`, `p12`). Now the extensions that do resolve to a mime type are still used to filter, and `*/*` is only used when none of them resolve.

## 1.0.1

- Improved package description, added example, and added missing API documentation.

## 1.0.0

- Initial release of Android implementation package for `file_picker`.
- Removed the Apache Tika dependency (~300 KB) used for MIME type detection in `saveFile()`. MIME types are now resolved from the file name extension via `MimeTypeMap`, with `URLConnection.guessContentTypeFromStream` as a content-sniffing fallback when no extension is available. [#2101](https://github.com/vicajilau/flutter_file_picker/issues/2101)







 
