Android Question How to save and restore App State in Multi-Page B4XProjects?

fredo

Well-Known Member
Licensed User
Longtime User
When I exit a programme, I want to continue where I left off when I exited the programme.

I consider saving the status of the page in "B4xPage_Foreground" via KVS2.

But how can I save the pages stack and how would I restore it at App start?

What's the best way to save and restore the state of a B4XPages project, especially when dealing with multiple (possibly nested) pages, so that if e.g. the app unexpectedly closes, it can be restarted with the exact same pages setup?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Consider whether you really want to save the full state. The app state will remain until the OS kills the process.
I'm not sure that it is the best UX to keep the state for a long time.

You should save it in B4XPage_Background of B4XMainPage and load it in B4XPage_Created of the main page.

B4XPages.GetManager.mStackOfPageIds will return the stack of pages (their ids). You can add the ids to a list and save it.
 
Upvote 0
Top