java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.jaapp.treeview.InMemoryTreeStateManager)
<p>When i am start activity at that time exception will occure in my app and this type of error show in log cat an you please help me. This three class i have put there can u guide me please. this code use at that time error cone  context.startActivity(new Intent(context, AnswerActivity.class));   this line use at that time occure error</p>

<pre><code>threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0)
        FATAL EXCEPTION: main
        java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.jaapp.treeview.InMemoryTreeStateManager)
        at android.os.Parcel.writeSerializable(Parcel.java:1160)
        at android.os.Parcel.writeValue(Parcel.java:1114)
        at android.os.Parcel.writeMapInternal(Parcel.java:479)
        at android.os.Bundle.writeToParcel(Bundle.java:1552)
        at android.os.Parcel.writeBundle(Parcel.java:493)
        at android.app.ActivityManagerProxy.activityPaused(ActivityManagerNative.java:1574)
        at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3334)
        at android.app.ActivityThread.access$2500(ActivityThread.java:132)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2078)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4669)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.io.NotSerializableException: com.jaapp.dto.QuestionsDto
        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1547)
        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1859)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1701)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1665)
        at java.util.HashMap.writeObject(HashMap.java:1025)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1229)
        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1587)
        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1859)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1701)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1665)
        at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1153)
        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:420)
        at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1251)
        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1587)
        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1859)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1665)
        at android.os.Parcel.writeSerializable(Parcel.java:1155)
</code></pre>

<p>Code:</p>

<pre><code>    class SimpleStandardAdapter extends AbstractTreeViewAdapter&lt;QuestionsDto&gt; {
        public String[] Colorname = { "#FFFF00", "#ACCC00", "#FF5D00" };
        Context context;

        WebView descriptionView;

        public SimpleStandardAdapter(final QuestionsActivity treeViewListDemo,
                final Set&lt;String&gt; selected,
                final TreeStateManager&lt;QuestionsDto&gt; treeStateManager,
                final int numberOfLevels) {
            super(treeViewListDemo, treeStateManager, numberOfLevels);
            context = treeViewListDemo;

        }

        private String getDescription(final QuestionsDto id) {
            final Integer[] hierarchy = getManager().getHierarchyDescription(id);
            Log.i("log_tag", "" + id.getQid());
            return id.getQquestion();
            // return "Node " + id + Arrays.asList(hierarchy);
        }

        @Override
        public View getNewChildView(final TreeNodeInfo&lt;QuestionsDto&gt; treeNodeInfo) {
            final LinearLayout viewLayout = (LinearLayout) getActivity()
                    .getLayoutInflater().inflate(R.layout.demo_list_item, null);
            return updateView(viewLayout, treeNodeInfo);
        }

        @Override
        public LinearLayout updateView(final View view,
                final TreeNodeInfo&lt;QuestionsDto&gt; treeNodeInfo) {
            Log.v("log_tag", "get item id:" + treeNodeInfo.getId());
            final LinearLayout viewLayout = (LinearLayout) view;
            /*
             * descriptionView = (WebView) viewLayout
             * .findViewById(R.id.demo_list_item_description);
             */

            final TextView descriptionView = (TextView) viewLayout
                    .findViewById(R.id.demo_list_item_description);

            descriptionView.setText(
                    Html.fromHtml(getDescription(treeNodeInfo.getId())),
                    TextView.BufferType.SPANNABLE);
            /*
             * descriptionView.loadData(getDescription(treeNodeInfo.getId()),
             * "text/html", "utf-8");
             */

            /*
             * Spanned marked_up = Html.fromHtml(myString);
             * textview.setText(marked_up.toString(),BufferType.SPANNABLE);
             */

            view.setBackgroundColor(Color.parseColor("#FFFF00"));
            descriptionView.setBackgroundColor(Color.parseColor("#00000000"));

            // levelView.setText(Integer.toString(treeNodeInfo.getLevel()));
            /*
             * final CheckBox box = (CheckBox) viewLayout
             * .findViewById(R.id.demo_list_checkbox);
             */
            // box.setTag(treeNodeInfo.getId());
            /*
             * if (treeNodeInfo.isWithChildren()) { box.setVisibility(View.GONE); }
             * else { box.setVisibility(View.VISIBLE);
             * box.setChecked(selected.contains(treeNodeInfo.getId())); }
             * box.setOnCheckedChangeListener(onCheckedChange);
             */

            /*
             * descriptionView.seton(new OnClickListener() {
             * 
             * @Override public void onClick(View v) { // TODO Auto-generated method
             * stub Log.i("log_tag", "Click" + treeNodeInfo.getId()); } });
             */
            return viewLayout;
        }

        @Override
        public void handleItemClick(final View view, final Object id) {

            final QuestionsDto longId = (QuestionsDto) id;
            final TreeNodeInfo&lt;QuestionsDto&gt; info = getManager()
                    .getNodeInfo(longId);

            if (info.isWithChildren()) {
                super.handleItemClick(view, id);
                Log.i("log_tag", "Click" + info.getId());

            } else {
                final ViewGroup vg = (ViewGroup) view;
                /*
                 * final CheckBox cb = (CheckBox) vg
                 * .findViewById(R.id.demo_list_checkbox); cb.performClick();
                 */

            }
            Log.i("log_tag", "Click Event Call ID::::: " + info.getId().getQid());
            Jaappdb.getanswer(info.getId().getQid());

            /*
             * Intent intent = new Intent(context, AnswerActivity.class);
             * intent.putExtra("key_QuestionId", info.getId().getQid());
             * context.startActivity(intent);
             */
            context.startActivity(new Intent(context, AnswerActivity.class));

        }

        @Override
        public long getItemId(final int position) {
            return position;
        }

    }
     ====================================================


    package com.example.treelistviewdemo.treeview;
    /**
     * In-memory manager of tree state.
     * 
     * @param &lt;T&gt;
     *            type of identifier
     */
    public class InMemoryTreeStateManager&lt;T&gt; implements TreeStateManager&lt;T&gt; {
        private static final String TAG = InMemoryTreeStateManager.class
                .getSimpleName();
        private static final long serialVersionUID = 1L;
        private final Map&lt;T, InMemoryTreeNode&lt;T&gt;&gt; allNodes = new HashMap&lt;T, InMemoryTreeNode&lt;T&gt;&gt;();
        private final InMemoryTreeNode&lt;T&gt; topSentinel = new InMemoryTreeNode&lt;T&gt;(
                null, null, -1, true);
        private transient List&lt;T&gt; visibleListCache = null; // lasy initialised
        private transient List&lt;T&gt; unmodifiableVisibleList = null;
        private boolean visibleByDefault = true;
        private final transient Set&lt;DataSetObserver&gt; observers = new HashSet&lt;DataSetObserver&gt;();

        private synchronized void internalDataSetChanged() {
            visibleListCache = null;
            unmodifiableVisibleList = null;
            for (final DataSetObserver observer : observers) {
                observer.onChanged();
            }
        }

        /**
         * If true new nodes are visible by default.
         * 
         * @param visibleByDefault
         *            if true, then newly added nodes are expanded by default
         */
        public void setVisibleByDefault(final boolean visibleByDefault) {
            this.visibleByDefault = visibleByDefault;
        }

        private InMemoryTreeNode&lt;T&gt; getNodeFromTreeOrThrow(final T id) {
            if (id == null) {
                throw new NodeNotInTreeException("(null)");
            }
            final InMemoryTreeNode&lt;T&gt; node = allNodes.get(id);
            if (node == null) {
                throw new NodeNotInTreeException(id.toString());
            }
            return node;
        }

        private InMemoryTreeNode&lt;T&gt; getNodeFromTreeOrThrowAllowRoot(final T id) {
            if (id == null) {
                return topSentinel;
            }
            return getNodeFromTreeOrThrow(id);
        }

        private void expectNodeNotInTreeYet(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = allNodes.get(id);
            if (node != null) {
                throw new NodeAlreadyInTreeException(id.toString(), node.toString());
            }
        }

        @Override
        public synchronized TreeNodeInfo&lt;T&gt; getNodeInfo(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrow(id);
            final List&lt;InMemoryTreeNode&lt;T&gt;&gt; children = node.getChildren();
            boolean expanded = false;
            if (!children.isEmpty() &amp;&amp; children.get(0).isVisible()) {
                expanded = true;
            }
            return new TreeNodeInfo&lt;T&gt;(id, node.getLevel(), !children.isEmpty(),
                    node.isVisible(), expanded);
        }

        @Override
        public synchronized List&lt;T&gt; getChildren(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            return node.getChildIdList();
        }

        @Override
        public synchronized T getParent(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            return node.getParent();
        }

        private boolean getChildrenVisibility(final InMemoryTreeNode&lt;T&gt; node) {
            boolean visibility;
            final List&lt;InMemoryTreeNode&lt;T&gt;&gt; children = node.getChildren();
            if (children.isEmpty()) {
                visibility = visibleByDefault;
            } else {
                visibility = children.get(0).isVisible();
            }
            return visibility;
        }

        @Override
        public synchronized void addBeforeChild(final T parent, final T newChild,
                final T beforeChild) {
            expectNodeNotInTreeYet(newChild);
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(parent);
            final boolean visibility = getChildrenVisibility(node);
            // top nodes are always expanded.
            if (beforeChild == null) {
                final InMemoryTreeNode&lt;T&gt; added = node.add(0, newChild, visibility);
                allNodes.put(newChild, added);
            } else {
                final int index = node.indexOf(beforeChild);
                final InMemoryTreeNode&lt;T&gt; added = node.add(index == -1 ? 0 : index,
                        newChild, visibility);
                allNodes.put(newChild, added);
            }
            if (visibility) {
                internalDataSetChanged();
            }
        }

        @Override
        public synchronized void addAfterChild(final T parent, final T newChild,
                final T afterChild) {
            expectNodeNotInTreeYet(newChild);
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(parent);
            final boolean visibility = getChildrenVisibility(node);
            if (afterChild == null) {
                final InMemoryTreeNode&lt;T&gt; added = node.add(
                        node.getChildrenListSize(), newChild, visibility);
                allNodes.put(newChild, added);
            } else {
                final int index = node.indexOf(afterChild);
                final InMemoryTreeNode&lt;T&gt; added = node.add(
                        index == -1 ? node.getChildrenListSize() : index + 1, newChild,
                        visibility);
                allNodes.put(newChild, added);
            }
            if (visibility) {
                internalDataSetChanged();
            }
        }

        @Override
        public synchronized void removeNodeRecursively(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            final boolean visibleNodeChanged = removeNodeRecursively(node);
            final T parent = node.getParent();
            final InMemoryTreeNode&lt;T&gt; parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
            parentNode.removeChild(id);
            if (visibleNodeChanged) {
                internalDataSetChanged();
            }
        }

        private boolean removeNodeRecursively(final InMemoryTreeNode&lt;T&gt; node) {
            boolean visibleNodeChanged = false;
            for (final InMemoryTreeNode&lt;T&gt; child : node.getChildren()) {
                if (removeNodeRecursively(child)) {
                    visibleNodeChanged = true;
                }
            }
            node.clearChildren();
            if (node.getId() != null) {
                allNodes.remove(node.getId());
                if (node.isVisible()) {
                    visibleNodeChanged = true;
                }
            }
            return visibleNodeChanged;
        }

        private void setChildrenVisibility(final InMemoryTreeNode&lt;T&gt; node,
                final boolean visible, final boolean recursive) {
            for (final InMemoryTreeNode&lt;T&gt; child : node.getChildren()) {
                child.setVisible(visible);
                if (recursive) {
                    setChildrenVisibility(child, visible, true);
                }
            }
        }

        @Override
        public synchronized void expandDirectChildren(final T id) {
            Log.d(TAG, "Expanding direct children of " + id);
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            setChildrenVisibility(node, true, false);
            internalDataSetChanged();
        }

        @Override
        public synchronized void expandEverythingBelow(final T id) {
            Log.d(TAG, "Expanding all children below " + id);
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            setChildrenVisibility(node, true, true);
            internalDataSetChanged();
        }

        @Override
        public synchronized void collapseChildren(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            if (node == topSentinel) {
                for (final InMemoryTreeNode&lt;T&gt; n : topSentinel.getChildren()) {
                    setChildrenVisibility(n, false, true);
                }
            } else {
                setChildrenVisibility(node, false, true);
            }
            internalDataSetChanged();
        }

        @Override
        public synchronized T getNextSibling(final T id) {
            final T parent = getParent(id);
            final InMemoryTreeNode&lt;T&gt; parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
            boolean returnNext = false;
            for (final InMemoryTreeNode&lt;T&gt; child : parentNode.getChildren()) {
                if (returnNext) {
                    return child.getId();
                }
                if (child.getId().equals(id)) {
                    returnNext = true;
                }
            }
            return null;
        }

        @Override
        public synchronized T getPreviousSibling(final T id) {
            final T parent = getParent(id);
            final InMemoryTreeNode&lt;T&gt; parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
            final T previousSibling = null;
            for (final InMemoryTreeNode&lt;T&gt; child : parentNode.getChildren()) {
                if (child.getId().equals(id)) {
                    return previousSibling;
                }
            }
            return null;
        }

        @Override
        public synchronized boolean isInTree(final T id) {
            return allNodes.containsKey(id);
        }

        @Override
        public synchronized int getVisibleCount() {
            return getVisibleList().size();
        }

        @Override
        public synchronized List&lt;T&gt; getVisibleList() {
            T currentId = null;
            if (visibleListCache == null) {
                visibleListCache = new ArrayList&lt;T&gt;(allNodes.size());
                do {
                    currentId = getNextVisible(currentId);
                    if (currentId == null) {
                        break;
                    } else {
                        visibleListCache.add(currentId);
                    }
                } while (true);
            }
            if (unmodifiableVisibleList == null) {
                unmodifiableVisibleList = Collections
                        .unmodifiableList(visibleListCache);
            }
            return unmodifiableVisibleList;
        }

        public synchronized T getNextVisible(final T id) {
            final InMemoryTreeNode&lt;T&gt; node = getNodeFromTreeOrThrowAllowRoot(id);
            if (!node.isVisible()) {
                return null;
            }
            final List&lt;InMemoryTreeNode&lt;T&gt;&gt; children = node.getChildren();
            if (!children.isEmpty()) {
                final InMemoryTreeNode&lt;T&gt; firstChild = children.get(0);
                if (firstChild.isVisible()) {
                    return firstChild.getId();
                }
            }
            final T sibl = getNextSibling(id);
            if (sibl != null) {
                return sibl;
            }
            T parent = node.getParent();
            do {
                if (parent == null) {
                    return null;
                }
                final T parentSibling = getNextSibling(parent);
                if (parentSibling != null) {
                    return parentSibling;
                }
                parent = getNodeFromTreeOrThrow(parent).getParent();
            } while (true);
        }

        @Override
        public synchronized void registerDataSetObserver(
                final DataSetObserver observer) {
            observers.add(observer);
        }

        @Override
        public synchronized void unregisterDataSetObserver(
                final DataSetObserver observer) {
            observers.remove(observer);
        }

        @Override
        public int getLevel(final T id) {
            return getNodeFromTreeOrThrow(id).getLevel();
        }

        @Override
        public Integer[] getHierarchyDescription(final T id) {
            final int level = getLevel(id);
            final Integer[] hierarchy = new Integer[level + 1];
            int currentLevel = level;
            T currentId = id;
            T parent = getParent(currentId);
            while (currentLevel &gt;= 0) {
                hierarchy[currentLevel--] = getChildren(parent).indexOf(currentId);
                currentId = parent;
                parent = getParent(parent);
            }
            return hierarchy;
        }

        private void appendToSb(final StringBuilder sb, final T id) {
            if (id != null) {
                final TreeNodeInfo&lt;T&gt; node = getNodeInfo(id);
                final int indent = node.getLevel() * 4;
                final char[] indentString = new char[indent];
                Arrays.fill(indentString, ' ');
                sb.append(indentString);
                sb.append(node.toString());
                sb.append(Arrays.asList(getHierarchyDescription(id)).toString());
                sb.append("\n");
            }
            final List&lt;T&gt; children = getChildren(id);
            for (final T child : children) {
                appendToSb(sb, child);
            }
        }

        @Override
        public synchronized String toString() {
            final StringBuilder sb = new StringBuilder();
            appendToSb(sb, null);
            return sb.toString();
        }

        @Override
        public synchronized void clear() {
            allNodes.clear();
            topSentinel.clearChildren();
            internalDataSetChanged();
        }

        @Override
        public void refresh() {
            internalDataSetChanged();
        }

    }


    ======================================================================================================
    package com.example.treelistviewdemo.treeview;
    import java.io.Serializable;
    import java.util.List;
    import android.database.DataSetObserver;
    /**
     * Manages information about state of the tree. It only keeps information about
     * tree elements, not the elements themselves.
     * 
     * @param &lt;T&gt;
     *            type of the identifier for nodes in the tree
     */
    public interface TreeStateManager&lt;T&gt; extends Serializable {

        /**
         * Returns array of integers showing the location of the node in hierarchy.
         * It corresponds to heading numbering. {0,0,0} in 3 level node is the first
         * node {0,0,1} is second leaf (assuming that there are two leaves in first
         * subnode of the first node).
         * 
         * @param id
         *            id of the node
         * @return textual description of the hierarchy in tree for the node.
         */
        Integer[] getHierarchyDescription(T id);

        /**
         * Returns level of the node.
         * 
         * @param id
         *            id of the node
         * @return level in the tree
         */
        int getLevel(T id);

        /**
         * Returns information about the node.
         * 
         * @param id
         *            node id
         * @return node info
         */
        TreeNodeInfo&lt;T&gt; getNodeInfo(T id);

        /**
         * Returns children of the node.
         * 
         * @param id
         *            id of the node or null if asking for top nodes
         * @return children of the node
         */
        List&lt;T&gt; getChildren(T id);

        /**
         * Returns parent of the node.
         * 
         * @param id
         *            id of the node
         * @return parent id or null if no parent
         */
        T getParent(T id);

        /**
         * Adds the node before child or at the beginning.
         * 
         * @param parent
         *            id of the parent node. If null - adds at the top level
         * @param newChild
         *            new child to add if null - adds at the beginning.
         * @param beforeChild
         *            child before which to add the new child
         */
        void addBeforeChild(T parent, T newChild, T beforeChild);

        /**
         * Adds the node after child or at the end.
         * 
         * @param parent
         *            id of the parent node. If null - adds at the top level.
         * @param newChild
         *            new child to add. If null - adds at the end.
         * @param afterChild
         *            child after which to add the new child
         */
        void addAfterChild(T parent, T newChild, T afterChild);

        /**
         * Removes the node and all children from the tree.
         * 
         * @param id
         *            id of the node to remove or null if all nodes are to be
         *            removed.
         */
        void removeNodeRecursively(T id);

        /**
         * Expands all children of the node.
         * 
         * @param id
         *            node which children should be expanded. cannot be null (top
         *            nodes are always expanded!).
         */
        void expandDirectChildren(T id);

        /**
         * Expands everything below the node specified. Might be null - then expands
         * all.
         * 
         * @param id
         *            node which children should be expanded or null if all nodes
         *            are to be expanded.
         */
        void expandEverythingBelow(T id);

        /**
         * Collapse children.
         * 
         * @param id
         *            id collapses everything below node specified. If null,
         *            collapses everything but top-level nodes.
         */
        void collapseChildren(T id);

        /**
         * Returns next sibling of the node (or null if no further sibling).
         * 
         * @param id
         *            node id
         * @return the sibling (or null if no next)
         */
        T getNextSibling(T id);

        /**
         * Returns previous sibling of the node (or null if no previous sibling).
         * 
         * @param id
         *            node id
         * @return the sibling (or null if no previous)
         */
        T getPreviousSibling(T id);

        /**
         * Checks if given node is already in tree.
         * 
         * @param id
         *            id of the node
         * @return true if node is already in tree.
         */
        boolean isInTree(T id);

        /**
         * Count visible elements.
         * 
         * @return number of currently visible elements.
         */
        int getVisibleCount();

        /**
         * Returns visible node list.
         * 
         * @return return the list of all visible nodes in the right sequence
         */
        List&lt;T&gt; getVisibleList();

        /**
         * Registers observers with the manager.
         * 
         * @param observer
         *            observer
         */
        void registerDataSetObserver(final DataSetObserver observer);

        /**
         * Unregisters observers with the manager.
         * 
         * @param observer
         *            observer
         */
        void unregisterDataSetObserver(final DataSetObserver observer);

        /**
         * Cleans tree stored in manager. After this operation the tree is empty.
         * 
         */
        void clear();

        /**
         * Refreshes views connected to the manager.
         */
        void refresh();
    }
</code></pre>
