title: Directory To Serialize/Deserialize Objects in Android?
body: <p>I am trying to serialize an object onClick and then in a ListFragment, grab all the files in that directory and put them into the array. I have the code to serialize and put the filenames into an ArrayList, but it does not work.</p>
  
  <p>What am I doing wrong? How can I make it so they both point to the same directory?</p>
  
  <p>Here is my code for serialization: </p>
  
  <pre><code> WIFIQRCODE =   "WIFI:T:"+PASSTYPE2+";S:"+SSID2+";P:"+PASS2;
  
                      OutputStream file = null;
                      try {
                          file = new FileOutputStream(SSID2+".ser");
                      } catch (FileNotFoundException e) {
                          e.printStackTrace();
                      }
                      OutputStream buffer = new BufferedOutputStream(file);
                      ObjectOutput output = null;
                      try {
                          output = new ObjectOutputStream(buffer);
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
  
                      assert output != null;
                      try {
                          output.writeObject(WIFIQRCODE);
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
  </code></pre>
  
  <p>And my code for getting the filenames in the ListFragment:</p>
  
  <pre><code> String[] filenames = getApplicationContext().fileList();
              List&lt;String&gt; list = new ArrayList&lt;String&gt;();
              for(int i = 0; i&lt;filenames.length; i++){
                  //Log.d("Filename", filenames[i]);
                  list.add(filenames[i]);
              }
              ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(),
                      android.R.layout.simple_list_item_1, filenames);
              setListAdapter(adapter);
          }
  </code></pre>
  
  <p>Any help would be appretitiated!</p>