Deleting file is not working

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Deleting file is not working

Post by gnor » Sat Jul 23, 2022 12:03 pm

Hello everyone!

As many times now, here i'm again having trouble deleting picture from folder on android...

I'm retrieveing the images from the same folder 'AKORIGINAL' i have created and view the pictures in datagridform. Also have succes to save the photos into another folder after getting the filename from datagridform row.
I have no success to implement to delete a picture from the same folder.
Explaining the situation to show that read and write permissions are ok, also the filename in tORIGINALFILENAME is working when retrieving from the above folder.
my code:

set the defaultFolder to "/storage/emulated/0/Documents/AKORIGINAL"

DELETE FILE "/storage/emulated/0/Documents/AKORIGINAL" & SLASH & tORIGINALFILENAME
delete URL("file:" & "/storage/emulated/0/Documents/AKORIGINAL" & SLASH & tORIGINALFILENAME)

The result is can't delete this file


Anyone can explain to me why is it?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Sat Jul 23, 2022 6:22 pm

You are trying to access the system document folder which isn't supported in LC yet. There are some restricted permissions there. Also, not all Android devices use that particular path so your code may fail on other devices.

I think we mentioned before that you should be using specialFolderPath("documents") instead, which is the private sandbox folder for your app. You have full control of that folder.

Also you don't need both versions of the delete command, but you probably knew that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Deleting file is not working

Post by stam » Sat Jul 23, 2022 7:36 pm

No experiemce with android but my understanding is that at least at present on mobile (both iOS and Android) you can only modify files in the app’s sandboxed Documents folder on mobile - ie specialFolderPath(“Documents”).
As such i woukd imagine this code would not work as this action is probably not (yet?) supported…

At least thats my non-validated understanding…

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Deleting file is not working

Post by richmond62 » Sat Jul 23, 2022 7:38 pm

is probably not (yet?) supported…
And from what I know about the tightly controlled mobile phone environments, is unlikely
to ever be supported.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Sat Jul 23, 2022 8:16 pm

richmond62 wrote:
Sat Jul 23, 2022 7:38 pm
is probably not (yet?) supported…
And from what I know about the tightly controlled mobile phone environments, is unlikely
to ever be supported.
I put in a feature request for it and the reply was that it was a good idea. Other apps have access, so with the correct setup I think LC could too. On the other hand, Android refuses access except when specifically requested by the user (i.e., some kind of dialog..) So we'll see.

I should also have mentioned that in my old Android 8 tablet, there is no system Documents folder at all, which means the OP's code may or will fail on older devices. I'm not sure if it exists on newer devices or whether some other app created a Documents folder on my Android 12 phone.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Deleting file is not working

Post by stam » Sat Jul 23, 2022 8:50 pm

On iOS, apps can access the icloud drive, like a non-application specific documents folder. So there is an API to do something like this, but not yet through LiveCode. I have no experience of Android but perhaps there is something similar. I hope that in the future this will be possible…

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Deleting file is not working

Post by FourthWorld » Sat Jul 23, 2022 10:19 pm

stam wrote:
Sat Jul 23, 2022 8:50 pm
On iOS, apps can access the icloud drive, like a non-application specific documents folder. So there is an API to do something like this, but not yet through LiveCode. I have no experience of Android but perhaps there is something similar. I hope that in the future this will be possible…
In the olden days Apple used to provide WebDAV access to user cloud services. Not sure if that's still available. Microsoft's OneCloud, AWS, Google Drive, Nextcloud, Box, DropBox, PCloud, and most others do.

There are some nice libraries for using WebDAV in LiveCode:
https://forums.livecode.com/viewtopic.p ... 77#p188099
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Sun Jul 24, 2022 5:51 am

If I remember right, the OP only needs local app access so the sandboxed documents folder should work fine.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deleting file is not working

Post by gnor » Sun Jul 24, 2022 8:09 am

Hi!

Thanks for everyone for their help.
Can i just clear what Jacques posted?
In system/documenrs folder i've created folder A and folder B let say.
So i have a third party camera app saves plctures into the folder in system/documents/A folder. From the same folder a dgform is polulated and from there user select a picture and save it to another folder in system/documents/B folder. So as far i see i can read and write to this created by me folders but delete needs another permission?
From folder A i want to delete the pictire.
And yes Jacqe, you have recommended to use specialfolderpath(documents) and i know the addvatages of it. The reason is i want to have some other solution is, because i'm not able to get mobilepickphoto camera running on android 12 stabilly. It works as it thinks, i have mentioned those in my other posts. Anything i have tried did not work. Sometimes after hit ok in camera app it does nothing just quit. Sometimes camera app does not open at all etc. So because all of the above, i save pictures into system folder documents A with a third party camera app, and from there i save it into my remote mysql db and into another system documents folder B.
But from the third party camera app that i use can not access the specialfolder document folder can i?
And lastly i use the same code on 4 tablet with android 12 on them, all the same. Plus 1 with android 11. File systems of them are the same.
Thanks again for all of you

Ps. Jacque if you might have anything for me will be appriciated
Using Livecode commmunity 9.6.3

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Sun Jul 24, 2022 6:17 pm

I understand now. Android only allows file deletion from the system folders if the user deletes it using a file manager, or by the app that created it. This is a security measure. In your case, a third party app created the file so only that app can delete it.

The actual problem is that the camera functions are not working for you. If it did, you would not need the third-party app. There might be a problem with the community edition of LC, there have been many bug fixes since then.

You could see if the camera app allows you to send a delete instruction to it. If so, that app should be able to remove the file. Or see if you can tell the app to send you the image instead of saving it to disk.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deleting file is not working

Post by gnor » Mon Jul 25, 2022 2:55 am

Thanks Jacque!

My original app uses mobilepickphoto to launch the camera, save pics and thumbnails etc. But unfortunately was not stable. So finally stick with the third party camera app with the mentioned inconviniences.
During my researces about mobilepickphoto it seemed that Panos has taken care of this in the LC 9.6 release. So i have tried to build my standalone with api 26 to 29, each time tested on different devices from android 7-12, neither of them works.
Wondering: is it possible to see somewhere what the code is of mobilepickphoto?

Thank you

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Mon Jul 25, 2022 3:33 am

What version is the community edition? Is that 9.6? I have a commercial license so I haven't paid attention to the free one. I've never needed mobilePickPhoto so I don't have any script handy. Maybe someone else does.

Do you have a link to the bug report?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deleting file is not working

Post by gnor » Mon Jul 25, 2022 5:29 pm

Thanks Jacque!

I do not have the link, but surely i have read it with the name of Panos. It said that the mobilepickphoto camera and library has been fixed at LC 9.6 with api 29. There was written to check permissions like camera access and read-write to external files, he also fixed it in code he has provided regarding to permission issues.
The number u bug was 25.. something if i recall it well.
I have found two of them.
Please see this:
" ================
LiveCode 9.6.2 STABLE comes with 49 changes since the last stable release (9.6.1), including:

New Features
- Support for the newly released MacOS Big Sur
- Support for building with Xcode 12.1, using the iOS 14.1 SDK
- New tsNet and mergExt builds, built with the iOS 14.1 SDK

Bug Fixes:
- Fixed crash with mobilePickPhoto on Android 11
- Fixed 'revIsSpeaking()' function on Windows
- Faster deployment to iOS simulator
- Several fixes related to modal dialogs on MacOS
- Several dictionary fixes and documentation improvements"

And also

Updates in the LiveCode open source project
35 pull requests were merged since the last issue.

New LiveCode releases
LiveCode 9.0.4 RC-2
Notable changes
ByteOffset: Fixed bug causing incorrect results
Fix crash when using inf in math ops
Fix encoding of svg paths containing relative commands
Fix Android openGL compositor surface height issue
Ensure mobilePickPhoto works in all Android devices
Fix video view closing when player control is grouped / ungrouped
Dozens of fixes to memory leaks

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deleting file is not working

Post by jacque » Sun Jul 31, 2022 7:53 pm

Sorry for the delay, I just noticed I didn't respond here yet. What version is the community edition? It may be too old for the fixes that came later. API 29 means that the LC IDE can build for that Android OS but it does not mean that setting the build target to API to 29 will fix the bug.

Android now requires apps to be built with API 30 and that will change to 31 soon, so it may be that the community edition of LC is too old. I think the update to support API 29 was a couple of years ago.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Deleting file is not working

Post by richmond62 » Sun Jul 31, 2022 9:06 pm

The last open source version of LiveCode is 9.6.3.

Post Reply

Return to “Android Deployment”