Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3083] File.exists on Android always returns true

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2011-08-25T16:59:46.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, filesystem, mobile
ReporterMatthew O'Riordan
AssigneeTony Guntharp
Created2011-08-16T05:24:06.000+0000
Updated2016-03-08T07:48:08.000+0000

Description

The exists() function of the Titanium.Filesystem.File always returns true on Android, even when the file does not actually exist.
var fileDoesNotExist = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'this-file-does-not-exist.js');
var fileDoesExist = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'app.js');

var label = Titanium.UI.createLabel({
  color: '#FFF'
});
label.text = 'Test presence of file that exists => ' + fileDoesExist.exists() +
  '\nTest presence of file that does not exist => ' + fileDoesNotExist.exists();

var win = Titanium.UI.createWindow({
  backgroundColor: '#000'
});
win.add(label);
win.open();
I have tested this with both Android 2.1.1 and Android 2.3.3, using the latest stable Titanium Mobile SDK 1.7.2

Comments

  1. Matthew O'Riordan 2011-08-16

    BTW. I have done some basic tests and this seems to be an issue with 1.7.2, 1.7.3 but not with 1.7.1
  2. Paul Dowsett 2011-08-25

    Thanks for the excellent code. I've moved this information to the existing ticket, TIMOB-4469. Cheers
  3. Paul Dowsett 2011-10-07

    Closing due to inactivity.

JSON Source