Android Question Delete file from SD card

strupp01

Active Member
Licensed User
Longtime User
I back up and import files to and from an SD card on my tablet. Thanks to help and a sample program from e.g. DonManfred now also works everything.
However, there are problems when deleting files on the SD card. I read a list of all files from the SD card and then I want to delete them. I do the deletion with the command

B4X:
OK = File.Delete ("/ storage /" & Storage.Root.Name & "/ Sicherheit_Mein_Haushaltsbuch", Temp.trim)

The Storage.Root.Name also corresponds to the name of the SD card. The file name is stored correctly in Temp.
As a result of OK, I always get False. The file is also not deleted. No error message is issued either.
I cannot find an example for deleting files from an SD card on the Internet.
What am I doing wrong? Is the delete command the right one? Who might have a sample program for deleting a file from SD card and can set this.
Greetings strupp01
 

DonManfred

Expert
Licensed User
Longtime User
Is it a real external sdcard or is it the internal sdcard?
If internal then you need to use file.dirrrootexternal + subpath

If external SDCard then you need to use the external storage class.
 
Upvote 0

strupp01

Active Member
Licensed User
Longtime User
It is a real external SD card. What I don't understand is how I have to use an external storage class. Can you find something about this on the Internet?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here is the link in this forum:
 
Upvote 0

strupp01

Active Member
Licensed User
Longtime User
I saw the example from @Erel. Unfortunately, there is no example here for deleting a file on a real SD card. Since I can't get any further and the files only have to be deleted once a month, I will do this by hand until an example appears in the forum.
Thanks to @DonManfred and @Mahares for your contributions.
Greetings strupp01
 
Upvote 0
Top