Aead write file in specific folder flutter - android

Anyone know how to access a particular folder in phone storage using flutter? i want to read a abc.MP4 file and save it to another location inside phone storage ?

You can check Reading-Writing-Files documentation, there explains to you how to do it.
And I guess you want to copy the File to another path so you can take a look on File.copy documentation
Future<File> copy (
String newPath
)

Related

Flutter create file in download folder

In my app I need to download some bills.
On IOS my users can easily find them when app is closed because it is stored in a dedicated folder easily findable. I achieve that with getApplicationDocumentsDirectory() from path_provider and the following option in plist :
<key>UISupportsDocumentBrowser</key>
<true/>
In android, downloaded files aren't put inside the download folder but inside the app data folder which is hard for a simple user to understand how to go in. What can I do to put bills (pdf) inside the Android Download folder ?
I use for the moment the method getExternalStorageDirectory() from path_provider for Android.
Based on #blackapps responses, I used the following hard coded path in Android and fallback to getExternalStorageDirectory() if folder didn't exist.
final Directory directory = Directory('/storage/emulated/0/Download');
if (!await directory.exists()) directory = await getExternalStorageDirectory();

How to move a file from my app's internal storage to the phone's download directory in Android Q (10)?

It seems that getExternalStoragePublicDirectory() is now deprecated, so I need an alternative.
Say I have file the foo.png in my app's internal storage. I can easily access this file with
val foo = File(context.filesDir, "foo.png")
My problem is that I want to move this file to the user's Downloads directory, so that they can see it on their phone.
This answer uses DownloadManager. Unfortunately this is an image I generate myself, not download from somewhere.
You have two options.
Use Storage Acces Framework to let the user choose the Download directory .
Use MediaStore to insert file to Download directory.

How can store data to my internal storage in Flutter not path_providers

I want to create a Directory like we have for whatsapp in my internal storage. I've checked path_providers but thats not exactly what I need.
I want to create a directory in our default internal storage where the Android, Downloads, Pictures are all present and store data to that folder.
As asked the path I need is /storage/emulated/0/MyFolder.
Please don't suggest path_providers or shared_preferences. I need to create a folder in the path where the File manager in our phone opens up.
Is it possible? If yes, please tell me how can I do it?
I got the answer to do this in Native Java
as
Environment.getExternalStoragePublicDirectory("myFolderName");
Just check if the directory already exists and create if not exists!

Keeping a text file in android

I am new to android and facing issue with file system usages.
I have seen several threads but i am still not able to find the answer which i am looking for my requirement.
I have a original file say test.xml which i want to keep somewhere in my eclipse project so that as soon as i install the app it should move my test.xml file into data directory so that i would be able to read it
please refere this link :
http://developer.android.com/training/basics/data-storage/files.html
I want to save my original file at : "/data/data/com.example.helloWorld/files"
I should be able to get the file handle form the below command
File file = new File(context.getFilesDir(), filename);
Please Note i dont want to save my file in asset folder.
Thanks,
Manish Bansal
I recommend you use assets as storage for your file initially as that will get compiled with your app, then once the user starts your app you check if your file exists and if not you can save the asset to the internal storage location as specified in the documentation, from there you can use the file as you like in the filesystem.

Android, how to choose save file location?

is there any solution how to choose the saving files location?
maybe with the original file browser, to choose the destination?
thank you!
All you need is Android Directory Picker
Better to save files with your app namespace:
String extStorage = Environment.getExternalStorageState();
path = extStorage+"/Android/data/com.mydomain.myapp/";
It will be deleted when app gets uninstalled.
Here is actually everything about data storing.
http://developer.android.com/guide/topics/data/data-storage.html
From the above link:
If you're using API Level 7 or lower, use
getExternalStorageDirectory(), to open a File representing the
root of the external storage. You should then write your data in the
following directory:
/Android/data/<package_name>/files/
It's probably easiest and expected to save this out to the dedicated area on the external SD card.
You can get this folder by calling
file://localhost/Applications/android-sdk-macosx/docs/reference/android/os/Environment.html#getExternalStoragePublicDirectory(java.lang.String)
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES)
You can also append a sub-folder to reference the source better ie. your app.
You can either choose DIRECTORY_PICTURES or DIRECTORY_MOVIES. If it's user created I'd probably stick to pictures.
To be helpful you can also call the media scanner to add it to the appropriate content provider system wide.
sendBroadcast( new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory()))
);
If you MUST get a file chooser going, which isn't the recomened approach to expose the user to the file system. Try the file chooser form Open Intents. http://www.openintents.org/en/node/164

Categories

Resources