Closed dattasid closed 1 week ago
This issue is stale because it has been open for 7 days with no activity.
We found out after two weeks of debugging (more functionality in app, so hard to pinpoint)
and not even this helped us await FilePicker.platform.clearTemporaryFiles();
We will now try file_selector
.
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Action item
The documentation main page must make developers targeting Android aware that
Gap in documentation
Nowhere in file_picker documentation is it mentioned that files will be cached on Android. I just happened to notice a log statement . Then I checked the cache for the media app I am building and sure enough, I was using 1GB of cache for no good reason. I was storing multiple copies of the same files that I was using for testing.
The issue is I would have greatly annoyed users, when they found the limited space on their devices rapidly dwindling. All because my app was building a pointless copy of their entire media library.
Root Cause
In FileUtils.java , openFileStream will always create a cached copy of the file.
I can see the reason why. It works around many corner cases. Remote URI, additional permissions for accessing content URIs as files, so many issues can be easily resolved by making a quick cache of the file.
Except, without any kind of cache management, this is a dangerous thing to do. Even if the files are small, the cache might eventually become big. With media files etc, the cache will become very big very fast.
Since many developers are not even aware that this is happening, they dont even know they might need to manage the cache, or at a minimum tell the users to clear the cache if they are having space issues.
Also, the user clearing cache indiscriminately will cause problems for many apps which allow users to resume playing the same file.
I see that this has been an issue for 4+ years so I dont suppose we can have a 'dont cache' option.
Conclusion
Please make developers aware that files on Android will be cached and the app will need to account for this.