external storage (sd-card) access
hello,
what's the correct way to access the external (memory-card) storage on an android phone? thx, uno
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 -
Use isExternalStoragePresent and getExternalStorageDirectory();
-
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.
-
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; -
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.