Android Question [B4XPages] Global Variables

aeric

Expert
Licensed User
Longtime User
In Default B4A, I used to declare my global variables in Main and then later I used Starter to declare global variables such as UserID, SQL and KeyValueStore variables.

How about B4XPages? Do we store these variable in B4XMainPage?
 

hatzisn

Expert
Licensed User
Longtime User
B4XPage is a class so if it is necessary to access the variable make it Public and then access it like f.e. Page1.VariableName. If you want to obfuscate it though (f.e. a string) then you should use the Process_Globals of Main or Starter because the strings in a Class are not obfuscated.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Yes, I would like to know any "best" practice so when we develop for B4i and B4J will follow the same convention. So I think the correct way is to put those variables in Main class.
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
This is the wrong solution.

Put it in B4XMainPage. This way it will be cross platform.

And for the obfuscation purpose?
I'm currently using a code module with only the strings requiring obfuscation, declared as public and using them from the other pages
 
Upvote 0
Top