I copy image from gallery to app directory like this:
file.copy("${(await getApplicationDocumentsDirectory()).path}/media/foo.jpg");
And it works. But when i restart app, file dissappears.
So how should i save images to keep them even after app restart?
The problem was in my other code. I was trying to copy file to the same path and it didn't work properly. So, I added if check and it resolved problem.
if(file.path != newPath){
await file.copy(newPath);
}
Related
I am building a flutter app (iOS/Android/MacOS/Windows/Web) which is able to download files, selected by the user. But where should I save those files? On MacOS/Windows its easy using path_provider and get the path of the downloads folder.
But where should I save the files on the other platforms? The downloads folder would be perfect because the users are able to use those files (.pdf) even without using the app, so the files are not app specific.
If you wish to save in download directory you can use
Directory appDownloadDir = await getDownloadsDirectory();
String appDownloadPath = appDownloadDir.path;
Or
getExternalStorageDirectory()//android
getApplicationDocumentsDirectory()// ios doesnt support access to download folder
This is the first time I've tried uploading files to a folder in GitHub, and I seem to be having some issues.
I've made a folder: https://github.com/sam-mahdi/SAVUS/tree/master/Test_Files..
And I'm trying to upload files to it.
However, the files just don't seem to upload, it permanently says "uploading 1 of 1 file", but never does anything.
If I click commit, it tells me to upload something.
If I try to upload another file, it says "Something went really wrong, and we can’t process that file.", and I refresh the page.
The strange part is, I have no issue uploading multiple files (the same files) in the main repository, I only have this problem trying to upload it in the folder I made.
I've tried to close and open my browser. I am using chrome for reference (I saw online sometimes you get this issue if you use firefox).
Am I doing something wrong? or missing something?
First, if possible, avoid '..' at the end of your TestFiles.. folder.
Then try again uploading those files, to check if those trailing '..' were the issue.
I am trying to test a html build. The thing was working right until I tried loading an image file from the asset folder.
In the asset folder I have two files: badlogic.jpg and test.png
They are both loaded the same way:
varname = new Texture(Gdx.files.internal("<filename>"));
The project is build with:
./gradlew html:superDev
Loading the badlogic.jpg file works just fine, but loading any other file in the same folder does not work and gives the following error:
GwtApplication: exception: Couldn't load image 'test.png', file does not exist
Couldn't load image 'test.png', file does not exist.
I am loading badlogic.jpg first. I have confirmed that both files are in the same folder.
This is not a problem on android and desktop.
Well, just as I posted the question I found the answer.
My first thought was that I needed to clear my browser cache. I cleared it multiple times but it didn't work.
But.... I was testing the project in one window and using another to do other things. The browser window I used to clear the cache was firefox, the window I used to test the project was chrome... So... that's why it didn't work.
It works now that I have cleared the cache in the browser I use to test the project.
I think its time for bed.
I have developed an application which read text file. In Emulator I have push the file in
\Data\Data\PackageName\File.txt and its working fine. But when I try to push file in Device its generate the error Read Only File System. I have try to remount directory as writable but the same error. Please help me how can I push file into device.
The folder you are trying is locked on non-rooted phones i.e no write permission and I guess the device you are trying on is not a rooted one. since emulator is sort of developer device which is said to be rooted that's why you can push file to that location.
So depending on your requirement you have to either use Assest folder or File system storage
Update: How to use assest folder
Resources r = getResources();
AssetManager assetManager = r.getAssets();
InputStream in = assetManager.open(filename);
In practice, we can push such file in assets folder. Assets folder is there for you to put such raw files to be used inside the application.
i am adding folder from other app folder and then put that folder in my app and i import folder files to my app file but i am getting error like no such file or directory while running.
If you're attempting to move folders between running iPhone applications, you can't because of the application sandbox that isolates the applications from each other.
If you're attempting to add files and folders to an Xcode project, you need to make sure they are added to the appropriate target. If they are resources like images, sounds, plist etc you must have Xcode copy them to the project folder to ensure they are included in the final product.