CreateFile + Exportfile do not work in Android app

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

CreateFile + Exportfile do not work in Android app

Post by ZAK »

Hello!
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]
        stat=status
        Select Status
          Case #PB_Status_Saved           ; File correctly saved
          Case #PB_Status_Error            ; File saving has failed
        EndSelect
EndProcedure
    
Procedure Quit() 
    End
EndProcedure
 
 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]
            Else     
                Debug Str(a) + ": write filed"
            EndIf    
        Next
    
        ExportFile(0, "text/plain")
        CloseFile(0) 
Else
    Debug "CreateFile filed"
EndIf

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:
https://disk.yandex.ru/i/by_Idn8rsflZCg or https://drive.google.com/file/d/1LSV6Pi ... 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.
Fred
Site Admin
Posts: 1506
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: https://esstudio.site/2019/02/16/downlo ... rdova.html but it somehow the open part is failed (file creation is OK).
Post Reply