title: How can I store a data structure such as a Hashmap internally in Android?
body: <p>In my Android application I'm trying to store a Map structure such as:<code>Map&lt;String, Map&lt;String, String&gt;&gt;</code>using internal storage. I've looked into using <code>SharedPreferences</code>, but as you know, this only works when storing primitive data types. I tried to use <code>FileOutputStream</code>, but it only lets me write in bytes...Would I need to somehow serialize the Hashmap and then write to file? </p>
  
  <p>I've tried reading through <a href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal" rel="noreferrer">http://developer.android.com/guide/topics/data/data-storage.html#filesInternal</a> but I can't seem to find my solution.</p>
  
  <p>Here's an example of what I'm trying to do:<br/></p>
  
  <pre><code>private void storeEventParametersInternal(Context context, String eventId, Map&lt;String, String&gt; eventDetails){
  
  Map&lt;String,Map&lt;String,String&gt;&gt; eventStorage = new HashMap&lt;String,Map&lt;String,String&gt;&gt;();
  Map&lt;String, String&gt; eventData = new HashMap&lt;String, String&gt;();
  String REQUEST_ID_KEY = randomString(16);
  .   //eventData.put...
  .   //eventData.put...
  eventStorage.put(REQUEST_ID_KEY, eventData);
  FileOutputStream fos = context.openFileOutput(EVENT_FILENAME, Context.MODE_PRIVATE);
  fos.write(eventStorage) //This is wrong but I need to write to file for later access..
  
  }
  </code></pre>
  
  <p>What is the best approach for storing this type of a data structure internally in an Android App? Sorry if this seems like a dumb question, I am very new to Android. Thanks in advance.</p>