T tamadon Active Member Licensed User Longtime User Nov 24, 2012 #1 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 Code: Copy 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.
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 Code: Copy 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.
T tamadon Active Member Licensed User Longtime User Nov 24, 2012 #2 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
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.
Beja Expert Licensed User Longtime User Nov 24, 2012 #3 Initialize the class on FirstTime then on Activity Pause, read the current properties then reinitialize again with the previous properties on Activity Resume. Click to expand... 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
Initialize the class on FirstTime then on Activity Pause, read the current properties then reinitialize again with the previous properties on Activity Resume. Click to expand... 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.
Erel B4X founder Staff member Licensed User Longtime User Nov 25, 2012 #4 You can use RandomAccessFile.WriteObject to write your structure to a file. Upvote 0
T tamadon Active Member Licensed User Longtime User Nov 26, 2012 #5 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
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.