Skip to content

Instantly share code, notes, and snippets.

@falkolab
Created March 17, 2016 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falkolab/e0ec5e70db04e36a3ad9 to your computer and use it in GitHub Desktop.
Save falkolab/e0ec5e70db04e36a3ad9 to your computer and use it in GitHub Desktop.
How to access to file in storage card `/sdcard/anyfolder/myfile` in Titanium SDK
// need storage permission to be added in manifest
function getFileFromExternalStorage(path) {
if(Ti.Filesystem.isExternalStoragePresent()) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, path);
var newPath = file.nativePath.split(Ti.Filesystem.separator + Ti.App.id).join('');
file = Ti.Filesystem.getFile(newPath);
if(file.exists()) return file;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment