Android Question [Solved] RandomAccessFile WriteB4XObject Problem

fixit30

Active Member
Licensed User
Dear All.

This is my first ever question on this forum as I have always managed to find the answer using the wealth of knowledge from previous questions so please be gentle with me!

From this thread: http://www.b4x.com/android/forum/threads/b4xobject-b4a-b4j-b4i-objects-serialization.48272/#content

Erel Says:

The following types are supported by WriteB4XObject:
Lists, Maps, String, primitives, user defined types and arrays. Only arrays of bytes and arrays of objects are supported (in B4A and B4J).
Including combinations of these types (a list that holds maps for example).

Note that if you plan to read user defined types that were written by B4i from B4A or B4J then the types must be declared in the main module.
I have created a Custom Type, however I get the following error when I call raf.WriteB4XObject

B4X:
java.lang.RuntimeException: java.lang.RuntimeException: Cannot serialize object: (ArrayList) [1, 2, 3]
If I use WriteObject or WriteEncryptedObject it works fine.

I believe this issue is related to my Custom Type containing a List.

Is this behaviour normal?

Attached is a very simple Sample Project which shows the problem.

Many Thanks.

Alan.

Edit: Also, in case it matters.

B4A Version: 4.30
RandomAccessFile Version: 2.00
 

Attachments

Last edited:

fixit30

Active Member
Licensed User
Hi Erel.

Many thanks for your confirmation of this issue.

Are you able to tell me when the next version will be available?

Regards.

Alan.
 

MrKim

Well-Known Member
Licensed User
I, too am seeing this problem, I have a map with a type.
B4X:
Dim MOL As Map
Type LOL(Sort As  Int, Fname As String, SWL As CustomListView)
    MOL.Initialize
    Dim Lol As LOL
    Lol.Initialize
    Lol.Fname = "SwipeList.swl"
    Lol.Sort = 1
    Lol.SWL = SwipeList
    MOL.Put("SwipeList", Lol)
    MOL.Put("ActiveZXZX", Lol)
    Dim Lol2 As LOL
    Lol2.Fname = "Trash.swl"
    Lol2.Sort = 2
    Lol2.SWL = Trash
    MOL.Put("Trash", Lol2)
    Dim Lol3 As LOL
    Lol3.Fname = "Trash.swl"
    Lol3.Sort = 2
    Lol3.SWL = Trash
    MOL.Put("Archive", Lol3)

    Dim R As RandomAccessFile

        File.Delete(File.DirInternal, "MOLZXZX")
        R.Initialize(File.DirInternal, "MOLZXZX", False)
        R.WriteB4XObject(MOL, 0)
I am guessing it is the CustomListView in the type?
 
Top