Android Question A Public List doesn't keep its Value

Daniel44

Active Member
Licensed User
Hi Everyone!

Well.. This time I'd like to know how to keep a Public list's value. I have a routine where I add a value to that List which it is in the Starter Module. This list keep the value but when I change to another activity module that value is gone. I need that value in order be able to work in another activity module. I don't know which is the mistake. Thanks
I declared this List in the Starter module this way:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
     Public Data As List
    
End Sub

I fill the list in the Main Module

B4X:
btnSalvar_Click
    
    Starter.Data.Initialize
    Starter.Data.Add(Datos)
    
    Starter.Verficar = True
    Activity.Finish
    StartActivity(Main)
    
    Log(Starter.DatosSorteo)
When it Change to Main that Value it seems to be.
Log:
(ArrayList) [48484]

But when I change again to another Activity Module X the value was deleted
Activity X Log:
(ArrayList) []

How Can I make a persistent value for that List? Thanks
 

kisoft

Well-Known Member
Licensed User
Longtime User
HI

You can use CallSubDelayed, or CallSubDelayed2 and pass the variable value from one activity to another.
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
Why are you running StartActivity(Main) in the Main activity? If you are trying to start another activity from Main, you don't need to call Activity.Finish. If you are in another activity and want to go back to Main, just call Activity.Finish (don't do StartActivity(Main)).
 
Upvote 0

Daniel44

Active Member
Licensed User
Why are you running StartActivity(Main) in the Main activity? If you are trying to start another activity from Main, you don't need to call Activity.Finish. If you are in another activity and want to go back to Main, just call Activity.Finish (don't do StartActivity(Main)).
Got it thanks
 
Upvote 0
Top