mc9
mc9

Reputation: 6349

Get internal application directory in Cordova + android

I would like to know how to get the path where the app is installed on Android using Cordova. I want to use file API to get this information.

I have tried the solution implemented in this question, namely:

function gotFS(fileSystem) {
    console.log("got filesystem");
    // save the file system for later access
    console.log(fileSystem.root.fullPath);
    window.rootFS = fileSystem.root;
}

document.addEventListener('deviceready', function() {                
    window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}, false);

However, this gives me some path to external storage: file:///storage/emulated/0/.

I think requestFileSystem gives you external storage path if there is one available. How can I force requestFileSystem to give me internal path? (/data/data/appname)

Upvotes: 0

Views: 1963

Answers (2)

jcesarmobile
jcesarmobile

Reputation: 53301

from cordova file 3.0.0, the default LocalFileSystem.PERSISTENT is the /data/data/app.package

on previous versions you can get it using

window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, success, fail);

Upvotes: 2

user2501548
user2501548

Reputation: 21

You will find the application folder at:

/data/data/"your package name"

you can access this folder using the DDMS for your Emulator. you can't access this location on a real device unless you have a rooted device.

Upvotes: 0

Related Questions