How can I save a HashMap to Shared Preferences in Android?
I would not recommend writing complex objects into SharedPreference. Instead I would use ObjectOutputStream
to write it to the internal memory.
File file = new File(getDir("data", MODE_PRIVATE), "map");
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file));
outputStream.writeObject(map);
outputStream.flush();
outputStream.close();