Search code examples
androidandroid-fragmentshashmapandroid-savedstate

Put HashMap<Integer, List<Integer>> in savedInstanceState


I have a problem with adding values in savedInstanceState in Android. I tried to find solution on the internet, but I cannot seem to find a solution. Maybe some of you might know where the problem is. I need to put HashMap> to savedInstanceState, and retrieve that onCreate method. Has anyone encountered and solved this problem? Thank you for your time.


Solution

  • you can use putSerializable. E.g.

    savedInstanceState.putSerializable("KEY", hashMapInstance);