Android Question [solved]How to save a file when you exit the program from the recent apps list

Maodge

Member
Licensed User
I know how to save a file when exit normally , like click keycode_back.
using code as
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
        Log("MAIN close")
        File.WriteString(File.DirInternal,"state.txt",i_btn)
    End If
End Sub

but when exit the program from the recent apps list,file not saved.
B4X:
Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
    Log("recent remove")
    File.WriteString(File.DirInternal,"state.txt",Main.i_btn)
End Sub

so, how can save a file in this case? Thanks
 

Attachments

  • test-exitsavefile.zip
    9.5 KB · Views: 224

DonManfred

Expert
Licensed User
Longtime User
so, how can save a file in this case?
You CANT.You are killing the app with the swipe from the list. That´s it. No event is raised.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You CANT.You are killing the app with the swipe from the list. That´s it. No event is raised.
No event is raised? That event is raised, it exists just for those cases!
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
and it works as expected.

but when exit the program from the recent apps list,file not saved.
Make sure the file is not created, because it should be there.
I just did a test, saving in the DirRootExternal and working perfectly.
 
Last edited:
Upvote 0
Top