app.ListFolder of downloads returns only files created by DS

344 views
Skip to first unread message

FrickelPit

unread,
Jan 13, 2022, 1:14:03 PM1/13/22
to DroidScript
Hi, i just realized, that in DS 2.5 app.ListFolder(app.GetSpecialFolder("Downloads"))  returns only files created by DS. Though it's possible to create files and check existence of files in the downloads folder. Is it a bug or intended behaviour?
I append an SPK where you can test the existence of files that are not returned by ListFolder. And another question: Why FileExists is nor case sensitive? 
ListDownloadFolder.spk

Steve Garman

unread,
Jan 13, 2022, 2:40:25 PM1/13/22
to DroidScript
That is not the behaviour I am seeing on my Device

I am getting files from the main Download folder but only the media files

If you add this line to the end of your OnStart function, what path does it show?
   alert(app.RealPath( downloadFolder ))

What version of Android are you using?

FileExists may not be case-sensitive in DroidScript, depending on your local filing system

It should be case-sensitive when run from an APK though my information on that could be out of date

FrickelPit

unread,
Jan 14, 2022, 1:58:06 AM1/14/22
to DroidScript
alert(app.RealPath( downloadFolder )) shows /storage/emulated/0/Download
My device is a Sony Xperia III (XQ-BT52) with Android 11
Are there different filing systems on android devices?

FrickelPit

unread,
Jan 14, 2022, 2:09:18 AM1/14/22
to DroidScript
The described behaviour concers files only. app.ListFolder returns ALL folders from download folder no matter who created them.

Chris

unread,
Jan 14, 2022, 12:32:33 PM1/14/22
to DroidScript
My Android 10 device shows only files created by DS as well.

This is the desired result from Google when targeting API 30, as DS 2.5 does.

This is also not being followed across different device manufacturers. It is a mess for real.

The only real strategy we have is beyond the scope of normal DS plugin how-to's.  If you are an experienced java / android coder, you can implement SAF and androidx.DocumentFile to access files... but from experience, this is a task.

Steve Garman

unread,
Jan 14, 2022, 2:49:49 PM1/14/22
to DroidScript
Thanks for that Chris that makes absolute sense

I was testing on a couple of Samsung devices. In my experience they are not exactly obsessed by sticking to documented practice

I can let my grandchildren have their phones back now and tell fhem they can uninstall DS if they want to

Steve Garman

unread,
Jan 14, 2022, 2:55:25 PM1/14/22
to DroidScript
As a matter of interest this is what I was testing when I saw Chris' post

1) Make sure DroidScript is not running
2) In the phone's browser open https://sgarman.net/dloadtest.html
3) Long-touch the red image and download (to the Download folder)
4) Open DroidScript and run the following code

////////////////////
downloadFolder = app.GetSpecialFolder("Downloads")

function OnStart()
{
        lay = app.CreateLayout( "Linear", "VCenter,FillXY" )
        lst = app.AddList(lay, app.ListFolder(downloadFolder,null,null,"alphaSort"), 0.8, 0.4)
        app.AddLayout( lay )
}
////////////////////

Check if the file
  aaaa_This_file_has_never_been_near_DS.jpg
appears

Chris

unread,
Jan 14, 2022, 4:07:08 PM1/14/22
to DroidScript

As you can see Steve, blank screen.  Nada 
Screenshot_20220114-160046.png

Dimon

unread,
Jan 14, 2022, 7:54:59 PM1/14/22
to DroidScript
For those who write applications for themselves and are not going to publish in the play market, you can ask Smart to make it possible to package with a targetSdkVersion of no more than 27, then there will be no problems with access.

суббота, 15 января 2022 г. в 00:07:08 UTC+3, Chris:

FrickelPit

unread,
Jan 15, 2022, 5:00:56 AM1/15/22
to DroidScript
Comparing DS with Mixplorer for example (which shows all files in download folder) turns out that DS lacks the option 'Allow management of all files' in android Settings>Apps & notifications>DroidScript>Permission>Allowed. The only options here are 'Allow access to media only' and 'Deny'. Wouldn't it be possible to add that option to DS as well?

Alan Hendry

unread,
Jan 15, 2022, 9:35:51 AM1/15/22
to DroidScript
HI,

It has been pointed out in other posts that if DS bypasses Scoped Storage (SS)
and your app does when it's running from DS Home or Edit 
then when you build your app and users download and install it also will need to bypass SS (or it will fail).
At some point it will be possible to apply to Google Play for an exemption, 
no announcement on when that will be or what the process will be. 
But DS and your app would both need an exemption.
I know that X-plore bypasses SS, so in theory DS and your apps could do the same, but there is a danger that if comes to Google's attention they could exclude such apps as Malware.

I can't find many details on Android folder/file security. 
I can list the contents of /Sys/Img and read the files, but I can't list the contents of /Sys.
So presumably it's similar to Un*x where each folder/file has permissions 
for Owner/Group/Public for Read/Write/Execute.

Regards, ah

FrickelPit

unread,
Jan 24, 2022, 3:01:54 PM1/24/22
to DroidScript
Thanks for your suggestions. Meanwhile i've made a different approach. It's not really satisfying, but suits my needs at first sight. I'm developping an app that uses databases and i want to provide export and import functionality. My problems occured when trying to pick database files from download folder. As i mentioned before ListFolder didn't fulfill my needs with scoped storage on Android 11 (Sony device). 
By using an intent the appended SPK is able to pick a file from the download folder and copy it to private folder. But some things are still strange. For example only mime type application/octet-stream allows to filter database files (and others!), though my files were created with (and still have) mime type application/x-sqlite3. The actually proposed mime type application/vnd.sqlite3 or the deprecated application/x-sqlite3 don't work. And i found out, that app.CopyFile only works if the source file is specified by URI. Using real path CopyFile doesn't work. Besides that i realized that app.Path2Uri throws an error in DS 2.5.
Hints regarding this theme are welcome!
Regards Peter

ImportDatabase.spk

Dave

unread,
Jan 26, 2022, 1:10:06 PM1/26/22
to DroidScript
Note: The next beta release of DS will allow use of /Internal/* and /External/* file paths and make use of SAF (Storage Access Framework) to ask the user for permission to read outside of the scoped storage sandbox (for premium users).

So you will be able to prompt the user to give permissions to sub folders under the main internal device storage or external sdcard storage.
Reply all
Reply to author
Forward
0 new messages