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

4 posts, 0 answers
  1. Felix De Lille
    Felix De Lille avatar
    18 posts
    Member since:
    Jun 2009

    Posted 14 Oct 2015 Link to this post

    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

     

     

     

  2. Martin Yankov
    Admin
    Martin Yankov avatar
    177 posts

    Posted 19 Oct 2015 Link to this post

    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.

     
  3. Felix De Lille
    Felix De Lille avatar
    18 posts
    Member since:
    Jun 2009

    Posted 21 Oct 2015 Link to this post

    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

  4. Martin Yankov
    Admin
    Martin Yankov avatar
    177 posts

    Posted 22 Oct 2015 Link to this post

    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.

     
Back to Top