I tested this flutter app example: https://github.com/tensor-programming/flutter_read_write_file_and_path
But, browsing my device with a file-manager (Solid Explorer), I cannot find the file "db.txt" created by this example.
final path = await localPath;
I checked in many folders including:
Where is this file? Should I root my device to find/see it?
What string to add after the "path" variable to reach the Download folder? Or, how to get the absolute path to the Download folder?
Device: GALAXY S8+ SM-G955F. Android 8.0. Not Rooted. Flutter beta v0.5.1. Dart 2.0.0-dev.58.0. Windows 10. Thanks and regards
For iOS it is NSDocumentDirectory . On Android, which is what you asked for, the directory can be found as /data/data/<package_name> and not as /data/<package_name> .
getApplicationDocumentsDirectory function Null safety On Android, this uses the getDataDirectory API on the context. Consider using getExternalStorageDirectory instead if data is intended to be visible to the user. Throws a MissingPlatformDirectoryException if the system is unable to provide the directory.
Directory generalDownloadDir = Directory('/storage/emulated/0/Download'); if you write whatever file you are trying to save to that directory, it will show up in the Downloads folder in any standard file manager application, rather than just the application-specific directory that the path_provider pkg provides.
You can do this
final Directory extDir = await getExternalStorageDirectory();
final String dirPath = extDir.path.toString().substring(0,20);
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/';
You might need to edit the parameters on the second line according to your platform for Android. This will create your file, and make it accessible to your users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With