Continuously writing data from different classes to a text file
<p>I have 3 different classes, 1 that monitors the accelerometer data, 1 that tracks GPS and one to write to a file.</p>

<p>I am using this code to write to the file in the accel and GPS class:</p>

<p>GPS</p>

<p><code>file.write(Latitude + "," + Longitude);</code></p>

<p>Accel</p>

<p><code>file.write(sensorEvent.values[0] + ", " + sensorEvent.values[1] + ", " + sensorEvent.values[2]);</code></p>

<p>Which goes to the write method in the file class;</p>

<pre><code>public void write(String message) {
    try {
        if (out == null) {
            FileWriter datawriter = new FileWriter(file);
            out = new BufferedWriter(datawriter);
        }
        if (file.exists()) {
            out.append(message);
            out.flush();

        }
    } catch (IOException e) {
        Log.e("Error", "fail to write file");
    }
}
</code></pre>

<p>The problem I'm having is that its only writing one line with the accel values in it and no GPS.</p>

<p>How do I write the a line that contains both accel and GPS values, and to keep writing those values to the same file.</p>
