This is a migrated thread and some comments may be shown as answers.

get app guid to get real file:/// path

3 Answers 219 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Felix De Lille
Top achievements
Rank 1
Felix De Lille asked on 14 Oct 2015, 06:06 PM

Hi,

I'm using requireJS and i want to set the baseURL to the root of my app which is this:

file:///data/data/com.telerik.TSTEST/files/12590FAA-5EDD-4B12-856D-F52A0A1599F2/

 

I can get the first part of the path with 

cordova.file.dataDirectory 

but how to get the last part (the APP Guid)?

 

Thanks

Felix

 

 

 

3 Answers, 1 is accepted

Sort by
0
Martin Yankov
Telerik team
answered on 19 Oct 2015, 01:55 PM
Hello Felix,

I'm a little bit confused by your question. You mention you want to get the root of your app, but then you point to the data storage directory. The root of your app should be at cordova.file.applicationDirectory + "www/". These will resolve to the locations where your app source files are located on each device platform. I believe this is what you need.

Regarding the data files folder - this is a data storage folder that is used for downloading files needed for your app. To the best of my knowledge there is no such thing as app GUID. All mobile apps are identified by their package ids. In your case this is com.telerik.TSTEST. The GUID that you see in this folder is most probably generated by a plugin that needed to download some files. Can you please explain why you think this is the root of your app?

I'm looking forward to your reply.

Regards,
Martin Yankov
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Felix De Lille
Top achievements
Rank 1
answered on 21 Oct 2015, 01:51 PM

Hi Martin,

Thanks, but it seems in simulator (and developer tools) that there is no www and it has added a UID at the end.

This seems to be device specific because in 2 different appBuilder projects, it gets the same UID when debugging on an android phone.

Greetings

Felix

0
Martin Yankov
Telerik team
answered on 22 Oct 2015, 03:10 PM
Hello Felix,

I get where your confusion comes from. The AppBuilder simulator is not a native emulator. It runs your HTML, JS and CSS in a Chrome webview. The simulator doesn't have the same file system as a native emulator or the actual devices. You should ignore the file paths that are shown there. The real paths to your app on each device are contained in the Cordova File plugin under the property cordova.file.applicationDirectory. This resolves to different things on each OS. Your HTML5 source code is located in the 'www' folder in these applicationDirectory folders. That being said I believe the baseUrl takes your root as the reference point and you should set your baseUrl like this:
({
  baseUrl: "./www/...",
  ...
})

Have you tried this out? Are you experiencing any problems with this approach?

Regards,
Martin Yankov
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
Apache Cordova
Asked by
Felix De Lille
Top achievements
Rank 1
Answers by
Martin Yankov
Telerik team
Felix De Lille
Top achievements
Rank 1
Share this question
or