Search code examples
androidout-of-memoryparcelableparcel

How many data a Parcel can store?


I encountered a problem using Parcelables to share Informations between Activitys. I have no Problem with the implementation, but with its behavior on some phones. It seems, that the information stored inside is just too much. This leads to MemoryExceptions thrown when that objects are getting unmarshalled. I couldn't find any kind of a memory-limit inside the docs. What is the best way to find out, if given Informations are small enaugh to write/read them into/from a Parcel, before the Parcelable is written to a Parcel?


Solution

  • I guess <= Integer.MAX_VALUE

    /**
     * Returns the total amount of data contained in the parcel.
     */
    public final native int dataSize();