Write to internal storage - File is empty
<p>I'm trying to write text files to internal storage in many ways. I don't know why the result text files are empty.</p>

<pre><code>package com.testandroid;

public class TestAndroidActivity extends Activity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        writeToInternalStorage(this);
    }

    private void writeToInternalStorage(final Context context) {
        try {
            // Way1
            final PrintWriter writer = new PrintWriter(new File("/data/data/com.testandroid/test.txt"));
            writer.println("Something");

            // Way2
            final PrintWriter writer2 = new PrintWriter(new FileOutputStream("/data/data/com.testandroid/test2.txt"));
            writer2.write("Something more");

            // Way3
            final FileOutputStream fos = openFileOutput("test3.txt", Context.MODE_PRIVATE);
            final PrintWriter writer3 = new PrintWriter(fos);
            writer3.write("Something of something");
            try {
                fos.close();
            } catch (final IOException e) {
                e.printStackTrace();
            }

            // Way4
            try {
                final BufferedWriter writer4 = new BufferedWriter(new FileWriter(new File("/data/data/com.testandroid/test4.txt")));
                writer4.write("Something please");
            } catch (final IOException e) {
                e.printStackTrace();
            }

        } catch (final FileNotFoundException e1) {
            e1.printStackTrace();
        }
    }
}
</code></pre>
