B4J Question What is the best way to keep variables available in each form in b4j

victormedranop

Well-Known Member
Licensed User
Longtime User
I need to maintain some variables in every form win b4j, i am using sqlite for that.
is there a better way to do that ?


Victor
 

OliverA

Expert
Licensed User
Longtime User
i am using sqlite for that.
I think your problem is a great fit for SQLite. If you don't want to maintain the SQL syntax between storing and retrieving your date, you could look into KeyValueStore2 and let it handle all the details for you (underneath, it uses SQLite). Plus, your stored data is encrypted (if that is a requirement). If you do not need to store the data between program executions, you could still use SQLite, but have it create in-memory database(s) only (without writing to disk). Since the source is available for KeyValueStore2, you could modify it to use a in-memory database.

Link(s):
https://www.b4x.com/android/forum/t...imple-powerful-local-datastore.63633/#content
https://www.sqlite.org/inmemorydb.html
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
If you go that far to write your own read write methods to serialize data to store and to retrieve your data and de-serialize it, why not just stick with KeyValueStore2? I do agree though that if writing is not needed, a class, declared globally, should suffice.
because often u have a class with functionality & data and typically you will save/load this by a own Sub or the easy way as Object to File.
b4xserializator is also a cool way for transport a object (or object list) via network from app to app.
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
If you go that far to write your own read write methods to serialize data to store and to retrieve your data and de-serialize it, why not just stick with KeyValueStore2? I do agree though that if writing is not needed, a class, declared globally, should suffice.

I will try both scenario an check for speed and complex of the solutions.

victor
 
Upvote 0
Top