Java tutorial
//package com.java2s; import android.util.Log; import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; import java.util.UUID; public class Main { private static Map<UUID, String> uuidsToNames = null; private static String fileName = "yourName"; public static void clearMap(File folder) { if (uuidsToNames != null) { uuidsToNames.clear(); } uuidsToNames = new HashMap<UUID, String>(); writePageNameHashesToFile(uuidsToNames, folder); } private static void writePageNameHashesToFile(Map<UUID, String> map, File folder) { if (uuidsToNames != null) { String mapString = "Map: "; for (Map.Entry<UUID, String> entry : uuidsToNames.entrySet()) { mapString += entry.toString(); mapString += "\n"; } } if (map == null) { // TODO: Do I need this? map = new HashMap<UUID, String>(); } try { FileOutputStream fos = new FileOutputStream(folder.getAbsolutePath() + fileName); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(map); oos.close(); } catch (Exception e) { Log.e("Write to file", e.toString()); } } }