Search code examples
javaandroidapache-mina

Android hashMap deserialize


I have server written in java SE, and a client is written in android, when I serialize an object Map in the client and then I pass it to the server and the server can't deserialize the object and vice versa. So, when I'm trying to deserialize another object like String, or Date, that's working fine.


Solution

  • Maps should usually be avoided in interfaces, especially when it involves serialization.

    Instead, try to replace your map by an other data structure containing the same data.

    For instance, create an object like:

    public class MyObject implements Serializable {
        Key keyOfMap;
        Value valueOfMap;
    }
    

    And send a List<MyObject> or equivalent.

    This should avoid all your map problems.