Search code examples
androidserializationdeserializationbinaryformatter

BinaryFormatter serialization/deserialization alternative in Android


I have a class serialized in C# using BinaryFormatter serialize method. Is there any way i can de-serialize it in android application. I mean is there any alternatives of BinaryFormatter in android?


Solution

  • Answering my own question after doing some research.

    In order to de-serialize objects in android (java) which were serialized in .Net, we have to serialize our class in .Net using custom serialization, i mean by using primitive datatypes instead of using built in .Net serializers. And then android application de-serialize in exact same order using primitive data types.

    To summarize we need to write primitive data types on stream in some order and in android read from stream the same primitive data types in exact same order they were written in .Net. XML can also be used for serializing and de-serializing

    Hope that helps