How to save object properties and restore them?

tamadon

Active Member
Licensed User
Longtime User
I am converting my app to OOP but am a bit stuck on how to save its properties in an efficient way.

For instance if I have declared the following Type in my Class module to represent the object's properties

B4X:
Type CatProperties (IsQuestion As Boolean, Level As Int, LevelCompleted As Boolean, ListBmpCat As List, QNo As Int, QTotal As Int, bmpCatQ As Bitmap)

How can I save those values on Activity Pause and then restore the object's properties (state?) on Activity Resume?

Or should I just use Public variables on the class module instead of declaring a Type? Then save their values on Activity Pause?

Thanks in advance.
 

tamadon

Active Member
Licensed User
Longtime User
Nevermind, I think I am going to try the following.

Initialize the class on FirstTime then on Activity Pause, read the current properties then reinitialize again with the previous properties on Activity Resume.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Initialize the class on FirstTime then on Activity Pause, read the current properties then reinitialize again with the previous properties on Activity Resume.

I would't be telling you the truth if I said I understood this..
in my mind, either your object properties are persistent by design or you save
the values in external storage device, such as a text file or database.
 
Upvote 0

tamadon

Active Member
Licensed User
Longtime User
Beja, you are right. However currently the object instance is only relevant to the activity instance. So I am saving it to several process global variables only.

If I need to access it outside of the activity later I'll need save the changes to a persistent storage at this point using RandomAccessFile.WriteObject.
 
Upvote 0
Top