eeadev
eeadev

Reputation: 3852

how to access via absolute path to my application's file - windows phone - Phonegap/Cordova

I am porting an application from android to wp8 using Phonegap/Cordova.

This is my source code structure:

enter image description here

In my index.html, I am getting logo.png this way (relative path):

<img src="img/logo.png" />

How to use the absolute path?

I tried in different ways (adding ms-appdata:///local/www/ or ms-app) but with no luck.

Upvotes: 1

Views: 1025

Answers (2)

salemk
salemk

Reputation: 33

the absolute path for Windows Phone is "//" !,

if( /Android|BlackBerry Mini/i.test(navigator.userAgent) ) {
    //android absolute path
    path = cordova.file.applicationStorageDirectory;
} else if (isWindowsPhone) {
    //windows phone absolute path
    path = "//";
} else {
    //iphone absolute path
    path = cordova.file.documentsDirectory;
}

Upvotes: 0

Ari Waisberg
Ari Waisberg

Reputation: 1303

You have to use the org.apache.cordova.file plugin and then you get a variable depending on the OS.

For example, I used (in Javascript using JQuery):

$("#myImage").attr("src", cordova.file.dataDirectory + "logo.png");

and that specific folder is for read/write files only access for your app. But there is more folders (directories) available.

See here: link where it says "Where to Store Files"

If it helped you, mark it as solved, please.

Upvotes: 4

Related Questions