app.GetAppPath()

93 views
Skip to first unread message

Tom Farrell

unread,
Jul 27, 2022, 11:30:07 PM7/27/22
to DroidScript
I am just wondering why "app.GetAppPath()" yields the string: "/android_asset/user"?  Of what use is it?  What is the proper way to obtain the actual location where an app stores its files?  (I tried everything I could find starting with "app.Get" and could not figure this out.  Thanks!

Right2TheV0id

unread,
Jul 28, 2022, 5:57:33 AM7/28/22
to DroidScript
If I understand well you want to know why app.GetAppPath gives a relative path in a generated APK?

Not 100% sure, but I presume this is a convenient abstraction because:
1. You can't really predict what the absolute path is and if it will change (depending on Android versions and updates),
2. Applications are placed in locations with limited access for non rooted users for security concern.
So working with absolute path is hazardous, relative paths should be sufficient.

I found those ressources that can give you complementary information:

Alan Hendry

unread,
Jul 28, 2022, 6:38:56 AM7/28/22
to DroidScript
Hi,

When your code runs under DS then AppPath is the path to where your source code and assets are stored by DS,
but if you build/install/run then Android has installed your app somewhere else (which you can't see, probably visible if you have root access).
Usually easier to use relative paths for your assets (they don't start with slash for example "Img/myimage.jpg").
Running under DS you can read from and write to AppPath/relative paths, but as an app you can only read it.
Technically to show a video requires update access, so to run your app you should extract elsewhere.

There's GetPath() "Returns the path to the local storage folder of the APK." 
running under DS that means the DS folder, but in your app it means your apps folder
(useful to write a small app that runs under DS, for example to backup your apps).

Regards, ah
Reply all
Reply to author
Forward
0 new messages