Write/Read any object to/from Android memory
<p>I'm currently writing to methods to:</p>

<ul>
<li>read object from memory</li>
<li>write object to memory</li>
</ul>

<p>I tried to save a String object and read it again, yet my code didn't work.</p>

<p>This is my code:</p>

<pre><code>public void writeObjectToMemory(String filename, Object object) {
        FileOutputStream fos;
        try {
            fos = game.openFileOutput(filename, Context.MODE_PRIVATE);
            ObjectOutputStream os = new ObjectOutputStream(fos);
            os.writeObject(object);
            os.close();
        } 
        catch (FileNotFoundException e) {
            e.printStackTrace();

        } 
        catch (IOException e) {
            e.printStackTrace();

        }

    }

    public void readObjectFromMemory(String filename, Object object) {
        FileInputStream fis;
        try {
            fis = game.openFileInput(filename);
            ObjectInputStream is = new ObjectInputStream(fis);
            object = is.readObject();
            is.close();
        } 
        catch (FileNotFoundException e) {
            e.printStackTrace();

        } 
        catch (StreamCorruptedException e) {
            e.printStackTrace();

        } 
        catch (IOException e) {
            e.printStackTrace();

        } 
        catch (ClassNotFoundException e) {
            e.printStackTrace();

        }

    }
</code></pre>
