Android vs ios filesystem


#1

Hi,
We are trying to display a list of users and their photo using the cordova library. For the iPhone the photo url is accessible using contacts.photos[0].value however the android can’t access it. The file must be downloaded first and saved to local storage. OK so having installed the cordova filesystem and file-transfer modules the following code is working on my phone.

The question is: How can I standardise this filestore location so that we can be sure it will work on all Devices? Or do all Androids use /storage/sdcard0/Android/AppName?

Is there any method for get this app file location?

savePhoto: function(userid,url){
var localstore = '/storage/sdcard0/Android/data/com.holladev/files/';
     $cordovaFile.downloadFile(url, localstore+userid+'.jpg', true).then(function(result){
                return friends[userid].photo = 'localstore'+userid+'.jpg';  
            }, function(error){
                console.log(error);
            });
    }

Thanks clever people for bringing us this awesome framework. We are very excited about our new playground :wink:


#2

You can use requestFileSystem() to obtain a managed file root, and then use getFile(“composed.id.jpg”) to get a file entry, finally pass the entry.toURL() to FileTransfer.

For you case, LocalFileSytem.TEMPRORY could be preferred for the requestFileSystem for temporary data. See Cordova File docs below 3.5 for more details.