CreateFile + Exportfile do not work in Android app

Found an issue in SpiderBasic ? Please report it here !
Posts: 1
Joined: Wed Nov 16, 2022 11:50 pm

CreateFile + Exportfile do not work in Android app

Post by ZAK »

The file is not saved in the case of an Android application when using the "CreateFile" and "ExportFile" procedures.
In the case of a WEB application, the entry in the Downloads directory was successful.
For the WEB and Android, the source code of the program is the same.

Code: Select all

; Slightly modified example from SB Help > CreateFile

Global stat.l=-999

Procedure Callback(Status, Filename$, File, SizeRead)
        Debug "Status="+Str(status) ; -- [b]NO DISPLAY THIS MESSAGE[/b]
        Select Status
          Case #PB_Status_Saved           ; File correctly saved
          Case #PB_Status_Error            ; File saving has failed
Procedure Quit() 
 OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_Background)
 W=WindowWidth(0) : H=WindowHeight(0)
 QuitBut=ButtonGadget(#PB_Any, W-100, H-40, 70, 25, "QUIT", #PB_Text_VerticalCenter)
 If CreateFile(0, "CreateFile Test.txt", @Callback())      ; we create a new text file
        For a=1 To 3  ; 10
            If WriteStringN(0, "Line "+Str(a)) 
                Debug Str(a)+": write OK"  ;       -- [b]DISPLAY THIS MESSAGE[/b]
                Debug Str(a) + ": write filed"
        ExportFile(0, "text/plain")
    Debug "CreateFile filed"

Debug "stat="+stat  ;   -- [b]DISPLAY INIT VALUE -999[/b]

BindEvent(#PB_Event_Gadget, @Quit()) 
The debug messages are the same(WEB, Android). I couldn 't insert a screenshot of the Debugger window. You can see it here: or ... share_link

In both cases, the "callback" procedure is not called, and its contents do not matter.

Versions SB 2.31 and 2.40 . Android version 10.
Site Admin
Posts: 1510
Joined: Mon Feb 24, 2014 10:51 am

Re: CreateFile + Exportfile do not work in Android app

Post by Fred »

You're right, I didn't found a way to trigger a download to the download directory using Cordova yet. I tried to use this: ... rdova.html but it somehow the open part is failed (file creation is OK).
Post Reply