How to get the path for a public folder file in cordova

Lets say I have /public/images/marker.png. Whats the best way to get the cordova local file path so I can hand it to the native google maps plugin for cordova. (For instance, for a marker icon)

This StackOverflow question is asking basically the same thing.

This finally worked for me.

getLocalPath = function(file) {
return cordova.file.applicationDirectory.replace(‘file://’, ‘’) + ‘www/application/’ + file;


I have tried that… also ‘www/application’ + file, and ‘www/’ + path, but nothing has worked :frowning: You were able to get the marker icon to show on the map?

what finally worked for me was

'www/application/app' + file

Yep that is the correct path now.

When I posted 3 months ago Cordova still hadn’t been upgraded and so it was a different path. Glad you figured it out!

Is this still working? I got some sound file in my public directory like ‘public/sounds/test.mp3’. I tried to access the file via

 var sound = new Sound('www/application/app/sounds/test.mp3');

but the sound couldn’t be loaded. Anyone an idea?

I read about that issue here

cordova.file.applicationDirectory + 'www/application/app/' + yourFilePath

gives me


which sees to be the correct path.