我有 3 个不同的类,1 个监视加速度计数据,1 个跟踪 GPS,一个用于写入文件。
我正在使用此代码写入加速和 GPS 类中的文件:
全球定位系统
file.write(Latitude + "," + Longitude);
加速
file.write(sensorEvent.values[0] + ", " + sensorEvent.values[1] + ", " + sensorEvent.values[2]);
转到文件类中的 write 方法;
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");
    }
}
我遇到的问题是它只写了一行加速度值,没有 GPS。
如何编写包含加速度和 GPS 值的行,并将这些值写入同一个文件。