Android Question [CLOSED] Storing CSBuilder into KeyValueStore2 ?

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
I would like to know if it should be possible to store a CSBuilder into KeyValueStore2, please.

My need is to prepare some sequences with their colors & links and then use them to easily feed Labels later.

My trouble is that I can store them when converted to Strings (CSB.ToString) but I can't when passed as objects.
java.lang.RuntimeException: Cannot serialize object: 

B4X:
Sub PrepareDB
Private CSB As CSBuilder
CSB.Initialize
CSB.Typeface(Typeface.MATERIALICONS)
CSB.BackgroundColor(Colors.Blue).Color(Colors.White).Append(Chr(0xE84D))
If Not(KVS.ContainsKey("csb1")) Then
KVS.Put("csb1",CSB)
End If
End Sub

And when I store as string, of course I lost the formatting.

Thanks
 

Attachments

  • csbkvsexample.zip
    8.2 KB · Views: 275

Cableguy

Expert
Licensed User
Longtime User
From what I could figure, you could pass your CSB into a list, and pass that list to the kvs2, or create your own type based on CSB, and pass that to kvs2
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Thanks Cableguy. It was a good idea but produces the same error as above. Well, it seems that I will have to use types and generate the labels on the fly so.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I never used kvs so I just took it from introductory post...
Since kvs is a class, can't you try to create your own methods inside it to work with your object type?
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
can't you try to create your own methods inside it to work with your object type?
Absolutely and I had try but the problem is with the char to serialize. It is the char that generates the error and I did not found any workaround, reason why I did ask :)
 
Upvote 0
Top