How to access Internal Storage of Android in Flutter
Solution 1
From Flutter sources:
/// Examples:
///
/// * iOS: `NSDocumentsDirectory`
/// * Android: The AppData directory.
static Future<Directory> getApplicationDocumentsDirectory() async {
return new Directory((await _pathProviderProxy.ptr.applicationDocumentsDirectory()).path);
Solution 2
To get internal storage directory path: For Legacy Use these flutter plugin that provides external storage path and external public storage path, ext_storage: ^latest_ver
String path = await ExtStorage.getExternalStoragePublicDirectory(
ExtStorage.DIRECTORY_DOWNLOADS);
Details:https://pub.dev/packages/ext_storage
external_path:^latest_ver, For NullSafety external_path is a flutter plugin that provides internal, external storage path and external public storage path,
String path=await ExternalPath.getExternalStoragePublicDirectory(
ExternalPath.DIRECTORY_DOWNLOADS);
Details:https://pub.dev/packages/external_path
Shubhamhackz
š Iām currently working on few flutter projects šÆ Iām looking to collaborate on open source projects š I regulary write articles on https://medium.com/@shubhamhackzz š¬ Ask me about flutter, dart and open source š± Iām currently learning Node.js and Express š« Through me a mail at [email protected] ā” Fun fact Google India Scholar 2018 (Android)
Updated on June 04, 2022Comments
-
Shubhamhackz almost 2 years
In android we use
getFileDir()
andgetCacheDir()
for accessing theInternal Storage
. I can see that there's apath_provider
plugin that I can use but I can only figure outgetTemporaryDirectory()
which is analogous togetCacheDir()
of android. So is there any alternative way of doing whatgetFileDir()
does in Android.Is there any other way to do this that I'm aware of, or I'm missing something.
-
Pete Houston over 5 yearsah ha nice spot :D
-
Shubhamhackz over 5 years@Mosbah It isn't really same as
getFileDir
because it returns pathdata/data/your_app_package/files
whereasgetApplicationDocumentDirectory
returns pathdata/data/your_app_package/flutter/app_flutter
, though we can useapp_flutter
directory instead offiles
without any issue -
uyhaW over 3 years@Mosbah can you provide full example of your code? cause I tried your code but I neet to define
_pathProviderProxy