[TIMOB-23494] Android: Support #createFile() method on Ti.Filesystem.File
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-10-31T14:52:10.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | Android |
| Labels | parity |
| Reporter | Christopher Williams |
| Assignee | Frankie Merzadyan |
| Created | 2016-06-10T18:59:11.000+0000 |
| Updated | 2017-01-31T19:55:19.000+0000 |
Description
Android is the only platform that doesn't support Ti.Filesystem.File#createFile(). We should ideally support it for parity's sake.
PR here: https://github.com/appcelerator/titanium_mobile/pull/8514
PR: https://github.com/appcelerator/titanium_mobile/pull/8514
Verified the implementation.
createFile()works as expected in android.Closing. Appc Studio : 4.8.1.201612050850 SDK Version : 6.1.0.v20170130073612 Mac OS Version : 10.12.2 Xcode Version : Xcode 8.2.1 Build version 8C1002 Appc CLI AND Appc NPM : {"NPM":"4.2.9-1","CLI":"6.1.0"} Ti CLI : 5.0.11 Alloy : 1.9.5 Node : v4.6.0 Nexus 6 running 6.0.1, Android emulator 7.1.1, android emulator 4.4.2var win = Ti.UI.createWindow({ layout:'vertical' }); var b1 = Ti.UI.createButton({ title:"tempdir", top:30 }); var b2 = Ti.UI.createButton({ title:"appdatadir", top:20 }); var b3 = Ti.UI.createButton({ title:"extstrdir", top:20 }); var b4 = Ti.UI.createButton({ title:"appcachedir", top:20 }); function tempFile(){ var Settings = Titanium.Filesystem.getFile(Titanium.Filesystem.tempDirectory,'Settings'); Ti.API.info("Created Settings: " + Settings.createDirectory()); Ti.API.info('Settings ' + Settings); var newFile = Titanium.Filesystem.getFile(Settings.nativePath,'Settings.txt'); newFile.createFile(); if (newFile.exists()){ newFile.write('I am in temp dir.'); alert('newfile: '+newFile.read()); } } function appdatadir(){ var Settings = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'Settings'); Ti.API.info("Created Settings: " + Settings.createDirectory()); Ti.API.info('Settings ' + Settings); var newFile = Titanium.Filesystem.getFile(Settings.nativePath,'Settings.txt'); newFile.createFile(); if (newFile.exists()){ newFile.write('I am in appl data dir.'); alert('newfile: '+newFile.read()); } } function extstrdir(){ if(Ti.Filesystem.isExternalStoragePresent()){ var Settings = Titanium.Filesystem.getFile(Titanium.Filesystem.tempDirectory,'Settings'); Ti.API.info("Created Settings: " + Settings.createDirectory()); Ti.API.info('Settings ' + Settings); var newFile = Titanium.Filesystem.getFile(Settings.nativePath,'Settings.txt'); newFile.createFile(); if (newFile.exists()){ newFile.write('I am in ext str dir.'); alert('newfile: '+newFile.read()); } } else{ alert("No ext storage present"); } } function appcachedir(){ var Settings = Titanium.Filesystem.getFile(Titanium.Filesystem.tempDirectory,'Settings'); Ti.API.info("Created Settings: " + Settings.createDirectory()); Ti.API.info('Settings ' + Settings); var newFile = Titanium.Filesystem.getFile(Settings.nativePath,'Settings.txt'); newFile.createFile(); if (newFile.exists()){ newFile.write('I am in app cache dir.'); alert('newfile: '+newFile.read()); } } b1.addEventListener('click',function(){ tempFile(); }); b2.addEventListener('click',function(){ appdatadir(); }); b3.addEventListener('click',function(){ extstrdir(); }); b4.addEventListener('click',function(){ appcachedir(); }); win.add([b1,b2,b3,b4]); win.open();