Android Question Save and share a value with other Activities

Matteo Granatiero

Active Member
Licensed User
I have an app that for the first time that is started, asks us what sex we are. That said I would save forever this value (male or female) and then pass it to the Activity 2 that according to the value (male or female) shows me a certain content or with
(If value ="male"then
button1.visible = true
else
button2.visible = true
end if)
So how do I save this string value in the app forever?
 

DonManfred

Expert
Licensed User
Longtime User
1. Please use [CODE]code here...[/CODE] tags when posting code.

codetag001.png

codetag002.png

codetag003.png


2. Check this tutorial
 
Upvote 0

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
There are many ways to do this.

You can also create a variable in Process_Globals of Starter Service and store the value.

"The Starter service should be the default location for all the public process global variables. SQL objects, data read from files and bitmaps used by multiple activities should all be initialized in the Service_Create sub of the Starter service."

https://www.b4x.com/android/forum/t...-consistent-single-entry-point.57599/#content
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
That said I would save forever this value (male or female)
Use a KeyValueStore object, defined as Public in the Process_Globals routine of the Starter module (initialize it in the Service_Create).
For example, if you named this object KVS, you can access values (stored permanently) from anywhere you want, like:

Starter.KVS.Put ("Sex", "Male")

If Starter.KVS.Get ("Sex") = "Male" Then


You could also use the StateManager code module.
 
Last edited:
Upvote 0
Top