Android Question Delete file using shell

Devv

Active Member
Licensed User
Longtime User
Hi all

i'm trying to delete a file from my phone sd card using a shell command

B4X:
Sub Process_Globals
    Dim p As Phone
End Sub

Sub Activity_Create(FirstTime As Boolean)
p.Shell("rm /sdcard/file1.txt", Null, Null, Null)
End Sub

i had imported the phone lib

1- when i run my app file1.txt is not deleted any ideas why ?
2- how can i use "file.DirRootExternal" instead of "/sdcard" in the command ?


note: i know that i can use file.delete but i want to use shell
when i type the same command to terminal emulator the file will be deleted !
 

Mahares

Expert
Licensed User
Longtime User
Try this. It will delete it for you:
B4X:
p.Shell("rm " & File.Combine(File.DirRootExternal,"file1.txt"), Null, Null, Null)
 
Upvote 0
Top