Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28230] Android: Add Ti.Filesystem.externalCacheDirectory support

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-11-16T21:39:35.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, cache, directory, file, filesystem
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-11-06T03:41:48.000+0000
Updated2020-11-16T21:39:35.000+0000

Description

*Summary:* On Android and iOS, we offer an [applicationCacheDirectory](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-property-applicationCacheDirectory) property used to write temporary files to internal storage. Android supports a sandboxed cache directory for the app on external storage, which typically provides more storage space. Unlike [externalStorageDirectory](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-property-externalStorageDirectory), the external cache directory is not automatically backed-up by the system. This makes it a good location for LARGE temporary files. We should expose this Android-only feature via the following property. Ti.Filesystem.externalCacheDirectory *Note 1:* You do *+NOT+* need the following permissions to read/write to the external cache folder. * READ_EXTERNAL_STORAGE * WRITE_EXTERNAL_STORAGE *Note 2:* You do *+NOT+* need to use the following APIs before reading/writing to this folder. * [Ti.Filesystem.hasStoragePermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-hasStoragePermissions) * [Ti.Filesystem.requestStoragePermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-requestStoragePermissions) *Note 3:* You do need to check the [isExternalStoragePresent()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-isExternalStoragePresent) method to see if external storage is mounted before using this folder. *Example:*
if (Ti.Filesystem.isExternalStoragePresent()) {
	const myFile = Ti.Filesystem.getFile(Ti.Filesystem.externalCacheDirectory, 'MyFile.txt');
	myFile.write('Hello World');
}

Comments

  1. Joshua Quick 2020-11-07

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12253
  2. Lokesh Choudhary 2020-11-16

    FR Passed. PR Merged.

JSON Source