Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

external storage (sd-card) access

hello,
what's the correct way to access the external (memory-card) storage on an android phone? thx, uno

— asked May 16th 2010 by u no
  • android
  • external-storage
  • filesystem
0 Comments

5 Answers

  • if(Ti.Filesystem.isExternalStoragePresent)
    {
      var dir = Ti.Filesystem.getExternalStorageDirectory();
      var url = dir + 'test.png';
      alert('ext storage present. url: ' + url);
    }
    

    returns appdata://test.png, which isn't ok. any idea?
    thx, uno

    — answered May 17th 2010 by u no
    permalink
    0 Comments
  • Use isExternalStoragePresent and getExternalStorageDirectory();

    — answered May 16th 2010 by Don Thorp
    permalink
    0 Comments
  • Ti.Filesystem.isExternalStoragePresent is a method. So use Ti.Filesystem.isExternalStoragePresent().

    Ti.Filesystem.getExternalStorageDirectory() indeed returns appdata:// (at least on Android). It maps to /sdcard/<app-id>/, so that seems fine.

    — answered March 25th 2011 by Mark Ruys
    permalink
    0 Comments
  • hi u no,
    your answer was the key in android;however, the only change I made is to remove the two curly braces after the nativePath "()" so it will be var path=file.nativePath;

    — answered March 13th 2013 by Talal Manaa
    permalink
    0 Comments
  • it's while ago… meanwhile i use:

    var file=Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory,'myfile');
    

    and for the real path:

    var path=file.nativePath();
    

    best, u.

    — answered March 25th 2011 by u no
    permalink
    1 Comment
    • hi u no, your answer was the key in android;however, the only change I made is to remove the two curly braces after the nativePath "()" so it will be var path=file.nativePath;

      — commented March 13th 2013 by Talal Manaa
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.