Replacement for the deprecated Uri2Path?

80 views
Skip to first unread message

FrickelPit

unread,
Feb 21, 2025, 11:16:19 AM2/21/25
to DroidScript
Hi guys, in my app the user should be able to select an accessible folder, e.g. in the download folder, in which the app can save reports and similar. The selection and access permission works with GetPermission("ExtSDCard", <cp>). However, the function returns an encoded URI with which many file functions such as CopyFile do not work. Since the Uri2Path function was classified as deprecated, I looked for a replacement and created the following small function:
function myUri2Path(uri) {
    var split = decodeURIComponent(uri).split(":")
    return app.RealPath(app.GetInternalFolder()).split("/Android/data")[0] + "/" + split[split.length - 1]
}
I would be interested to hear what you think about this and whether there is perhaps a better solution.
I am adding the SPK, which shows the way to my solution.

Regards Peter
myUri2Path.spk
Reply all
Reply to author
Forward
0 new messages