The following APIs need to use app's scoped storage and avoid external storage.
We should write temp files according to Google's docs in the link below. They expect us to explicitly set the temp directory to the app's cache directory.
Our Ti.Filesystem.tempDirectory property return...
Our Ti.Filesystem.createTempFile() and Ti.Filesystem.createTempDirectory() methods should change their base directory to the below to avoid collision with the above folder.
Our TiTempFileHelper.java code (used to acquire a temp directory path) will use getExternalCacheDir() or getCacheDir() depending on if it has access to external storage or not. This may not be a good idea since the temp directory can suddenly change at runtime due to...
- End-user granting permission, making it dynamically switch to external storage.
- End-user ejects SD card, which makes temp path switch to internal storage.
It would be better for the path to be consistent for the app's lifetime. So, it should be hardcoded to internal storage via getCacheDir() like Google's examples.
Our HTTP response cache should favor internal storage's cache directory for improved security/privacy. That is what Google suggests in the link below and is what the Chrome browser app does. External storage is best used for large files intended to be shared (like downloaded files).
If we do this, then we can remove our startExternalStorageMonitor() related code in TiApplication.java and hard-code our TiResponseCache to always be the default. This means HTTP response caching will alway be enabled, even if you don't have external storage permission.