Delete folder and all its content on Android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Delete folder and all its content on Android
Having the need to delete a folder, that was loaded to an Android standalone using the setting pane, I worked on the scripts of this lesson:
https://lessons.livecode.com/m/4071/l/1 ... ers-part-2
I came up with the attached stack, that works fine on OSX Sonoma with LC10DP1.
I think that something like this should appear in a LC lesson for mobile devices, particularly for whoever works with a Launcher, to build their standalone.
In my case, the Launcher App should be able to update from the cloud the real stack inside which will be in the loaded folder, together with other stuff.
When I tested to an Android 13 device, I got mixed results. So much that it is difficult to say what has been deleted and what is not.
I hope that someone can spread a light on this problem (next I will have to test it on iOS).
Receipt:
1 inside the main folder there is a "Storage" folder, where, for commodity, I keep the folder "Referi_0" used for testing
2 The "Referi_0" folder is light enough. I suggest to start with this one
3 make a copy of "Referi_0" to the same level of the DeleteFolder stack
4 Open the stack and be sure to update, in the standlone settings copy pane, the name of the folder to be loaded inside the standalone
5 Test the stack on OSX or Windows: your "Referi_0 folder should get deleted
6 Re-do step 3 to 4 and, this time, try to install on an Android device
You will see that the list of what has been deleted and what is not gets rather confused. I could not make sense of it.
If you feel like, test it on iOS and let me know.
https://lessons.livecode.com/m/4071/l/1 ... ers-part-2
I came up with the attached stack, that works fine on OSX Sonoma with LC10DP1.
I think that something like this should appear in a LC lesson for mobile devices, particularly for whoever works with a Launcher, to build their standalone.
In my case, the Launcher App should be able to update from the cloud the real stack inside which will be in the loaded folder, together with other stuff.
When I tested to an Android 13 device, I got mixed results. So much that it is difficult to say what has been deleted and what is not.
I hope that someone can spread a light on this problem (next I will have to test it on iOS).
Receipt:
1 inside the main folder there is a "Storage" folder, where, for commodity, I keep the folder "Referi_0" used for testing
2 The "Referi_0" folder is light enough. I suggest to start with this one
3 make a copy of "Referi_0" to the same level of the DeleteFolder stack
4 Open the stack and be sure to update, in the standlone settings copy pane, the name of the folder to be loaded inside the standalone
5 Test the stack on OSX or Windows: your "Referi_0 folder should get deleted
6 Re-do step 3 to 4 and, this time, try to install on an Android device
You will see that the list of what has been deleted and what is not gets rather confused. I could not make sense of it.
If you feel like, test it on iOS and let me know.
- Attachments
-
- Delete Folder.zip
- (141.81 KiB) Downloaded 262 times
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
Re: Delete folder and all its content on Android
Hi Trevix,
1. you can use -> specialfolderpath("resources") on all platforms: Mac, Win, iOS and Android!
specialfolderpath("resources") = specialfolderpath("engine") on mobile!
So no need to differ in your script(s):
2. We do NOT have write permissions (and deleting means WRITING) inside of the the app folder on the mobile platform,
so any attempt to delete a file or folder in -> specialfolderpath("resources") will FAIL and the script(s) will silently stop at this point.
We ONLY have write permission in -> specialfolderpath("documents")
Best
Klaus
1. you can use -> specialfolderpath("resources") on all platforms: Mac, Win, iOS and Android!
specialfolderpath("resources") = specialfolderpath("engine") on mobile!
So no need to differ in your script(s):
Code: Select all
...
# switch the platform
# case "MacOS"
# put specialFolderPath("resources") & "/" & tFolderName into sMainDirectory --inside the app, where to save the zip file
# break
# case "iPhone"
# case "Android"
# put specialFolderPath("engine") & "/" & tFolderName into sMainDirectory --inside the app, where to save the zip file
# break
# end switch
put specialFolderPath("engine") & "/" & tFolderName into sMainDirectory
...
so any attempt to delete a file or folder in -> specialfolderpath("resources") will FAIL and the script(s) will silently stop at this point.
We ONLY have write permission in -> specialfolderpath("documents")
Best
Klaus
Re: Delete folder and all its content on Android
Oh God! I got it all wrong...
Since this is "MY" sandBox, I was wrongly assuming that, in mobile also, I could write, save and delete inside it.
If this is not the case, are you saying that a developer, using a launcher method on mobile, saves his real stuff to the document folder?
In my case, in order to have an App that can update itself, the launcher should download from my server a Zip file, containing the LC stack and other resources, to the SpecialFolderpath("documents"), unzip it there and launch the unzipped LC stack which holds the app code.
Does it make sense?
Any suggestions are welcomed.
Creating a minimal launcher/splash stack as standalone, allows the launcher to start a LC stack loaded in the sandbox. And it does work fine on OSX, allowing also to do auto-updates without passing trough the stores.We do NOT have write permissions (and deleting means WRITING) inside of the the app folder on the mobile platform
Since this is "MY" sandBox, I was wrongly assuming that, in mobile also, I could write, save and delete inside it.
If this is not the case, are you saying that a developer, using a launcher method on mobile, saves his real stuff to the document folder?
In my case, in order to have an App that can update itself, the launcher should download from my server a Zip file, containing the LC stack and other resources, to the SpecialFolderpath("documents"), unzip it there and launch the unzipped LC stack which holds the app code.
Does it make sense?
Any suggestions are welcomed.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
Re: Delete folder and all its content on Android
Yes, that is the way to go with the "splash screen approach"!
On the very first launch of your app copy all folders and files from
-> specialfolderpath("resources") to -> specialfolderpath("documents")
and then start your "actual app" from there.
On the very first launch of your app copy all folders and files from
-> specialfolderpath("resources") to -> specialfolderpath("documents")
and then start your "actual app" from there.
Re: Delete folder and all its content on Android
Mumble...
While it works on desktop, the command "Rename folder", to move a folder and its content from "resources" to "Documents", does not work on mobile.
"Rename folder" does not copy. It moves the folder (or I guess it copies to "Document" and deletes in "Resources").
Perhaps because, as you said, in mobile we don't have permissions except in the "documents" folder. Delete in "Resources" is a no no.
The only option remains to save file by file, folder by folder, using the "put into Url" command and "create folder". What a drag if you have several nested folders.
Am I correct?
This Launcher thing is getting more complicated than I thought.
While it works on desktop, the command "Rename folder", to move a folder and its content from "resources" to "Documents", does not work on mobile.
"Rename folder" does not copy. It moves the folder (or I guess it copies to "Document" and deletes in "Resources").
Perhaps because, as you said, in mobile we don't have permissions except in the "documents" folder. Delete in "Resources" is a no no.
The only option remains to save file by file, folder by folder, using the "put into Url" command and "create folder". What a drag if you have several nested folders.
Am I correct?
This Launcher thing is getting more complicated than I thought.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
Re: Delete folder and all its content on Android
Hi Trevix,
don't shoot the messenger, thank you!
Yes, you are correct, everything should happen in the users Documents folder.
No "rename folder", "rename file" etc. on mobile.
We even cannot open a SQLite database file in the "resources" folder, since OPEN is already seen as EDITING on mobile.
So we also have to copy it to the "documents" folder and open it from there.
There is a feature request for accessing other, "common" folders like "Downloads" on Android:
https://quality.livecode.com/show_bug.cgi?id=23526
Best
Klaus
don't shoot the messenger, thank you!
Yes, you are correct, everything should happen in the users Documents folder.
No "rename folder", "rename file" etc. on mobile.
We even cannot open a SQLite database file in the "resources" folder, since OPEN is already seen as EDITING on mobile.
So we also have to copy it to the "documents" folder and open it from there.
There is a feature request for accessing other, "common" folders like "Downloads" on Android:
https://quality.livecode.com/show_bug.cgi?id=23526
Best
Klaus
Re: Delete folder and all its content on Android
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
Re: Delete folder and all its content on Android
I am wondering: once my standalone has loaded the working stack, in the Documents folder, can this last close and remove from memory the splash stack(the standalone)? Or should it stay loaded, may be hidden?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
Re: Delete folder and all its content on Android
You already wrote it: Your "splash" stack Is the runtime so it cannot be closed.
Just hide it.
Just hide it.