B4J Question Writing views in lists to file. How?

Marc De Loose

Member
Licensed User
Longtime User
Hi,

I am trying to write a list containing custom views to a file.
File.WriteList("./", "Test.txt", lst_xRotateKnobs)
lst_xRotateKnobs = File.ReadList("./", "Test.txt")

does not give the correct results.

What is the best way to save my list containing customview (class module)?

thx
 
Tried this:
B4X: Copy
Dim kvs As KeyValueStore
    kvs.Initialize("./","test.dat")
    kvs.Put("1",lst_xRotateKnobs)
lst_xRotateKnobs is a list
But it gave me a java error (keyvaluestore). Cannot serialize object.
 
Upvote 0
Use file.writelist function
 
Upvote 0
Tried this:
B4X: Copy
Dim kvs As KeyValueStore
    kvs.Initialize("./","test.dat")
    kvs.Put("1",lst_xRotateKnobs)
lst_xRotateKnobs is a list
But it gave me a java error (keyvaluestore). Cannot serialize object.
kvs should put an object for list.

B4X: Copy
kvs.PutObject("1",lst_xRotateKnobs)
 
Last edited:
Upvote 0
Tried this:
B4X: Copy
Dim kvs As KeyValueStore
    kvs.Initialize("./","test.dat")
    kvs.Put("1",lst_xRotateKnobs)
lst_xRotateKnobs is a list
But it gave me a java error (keyvaluestore). Cannot serialize object.
Which version is the kvs you are using?
 
Upvote 0
I am trying to write a list containing custom views to a file.
What do you mean? What does lst_xRotateKnobs contain? I guess xRotaryKnob views. If so, I don't think you can do that.
You can save data about the views, their state. You could create a custom type (declared in B4XMainPage or Main Activity) and use serialization to save the variable of this type, even a List of containing variables of this type.
 
Upvote 0
What do you mean? What does lst_xRotateKnobs contain? I guess xRotaryKnob views. If so, I don't think you can do that.
You can save data about the views, their state. You could create a custom type (declared in B4XMainPage or Main Activity) and use serialization to save the variable of this type, even a List of containing variables of this type.
B4J example attached (TextFields instead of xRotaryKnobs but the concept is the same)
 

Attachments

Upvote 0
What is the best way to save my list containing customview (class module)?
You can not store Objects or read Objects back.

All you can do is to save the data you need to create a new instance of the Object and create a new instance setting all values that you have set before.

See LucaMS Answers about a customtype you can use to realize it.
 
Upvote 0
Back
Top