What is the main difference between await getTemporaryDirectory();
and await getApplicationSupportDirectory()
with Flutter Path provider package.
CodePudding user response:
As per documentation :
Path to the temporary directory on the device that is not backed up and is suitable for storing caches of downloaded files.
Files in this directory may be cleared at any time. This does not return a new temporary directory. Instead, the caller is responsible for creating (and cleaning up) files or directories within this directory. This directory is scoped to the calling application.
On iOS, this uses the NSCachesDirectory API.
On Android, this uses the getCacheDir API on the context.
getApplicationSupportDirectory :
Path to a directory where the application may place application support files.
Use this for files you don’t want exposed to the user. Your app should not use this directory for user data files.
On iOS, this uses the NSApplicationSupportDirectory API. If this directory does not exist, it is created automatically.
On Android, this function uses the getFilesDir API on the context.
CodePudding user response:
It is mentioned that what is the underlying calls made for the function:
getTemporaryDirectory , getApplicationSupportDirectory
Considering the example of Android, the path returned by both methods should be used for storing the app-related data.
But there is a minor difference that for the files inside the path returned by getTemporaryDirectory
, the system will automatically delete files in this directory as disk space is needed elsewhere on the device. The system will always delete older files first, based on the lastModifiedTime.
Storage permission won't be required for both the methods.