0

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)

Community
  • 1
  • 1
mc9
  • 6,121
  • 13
  • 49
  • 87
  • which plugin version are you using? the latest should use ```/data/data/appname``` – jcesarmobile Oct 27 '15 at 09:01
  • @jcesarmobile You're right. From 3.0.0, the default persistent file location is internal. Can you post it as an answer? I will accept it. For people experiencing this issue: check out release note https://github.com/apache/cordova-plugin-file/blob/master/RELEASENOTES.md#300-aug-18-2015 – mc9 Oct 27 '15 at 22:36

2 Answers2

2

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);
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
0

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.

  • I want to use file API to retrieve that information. I am aware of this as you can see in the question. I will update the question to be more precise. – mc9 Oct 27 '15 at 05:52