0

I´m trying to save my values to .csv file with this code.

try {
    CSVWriter writer = new CSVWriter(new FileWriter(getFilesDir()+"ECGValues.csv"),',');
    // feed in your array (or convert your data to an array)
    String[] entries = Values_to_save.toArray(new String[Values_to_save.size()]);
    writer.writeNext(entries);
    writer.close();
    Values_to_save.clear();
    Toast.makeText(this,"ECG values saved", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
    Toast.makeText(this,"Error while saving values", Toast.LENGTH_SHORT).show();
    Log.e("error", "" + e.getMessage());
    Log.e("error",""+ e.getStackTrace());
}

My input data is from

Lead_I_save =String.valueOf(IValue);
Lead_II_save = String.valueOf(IIValue);
Lead_III_save = String.valueOf(IIIValue);
Lead_aVL_save = String.valueOf(aVLValue);
Lead_aVF_save = String.valueOf(aVFValue);
Lead_aVR_save = String.valueOf(aVRValue);
String newLine = String.format("%1$s;%2$s;%3$s;%4$s;%5$s;%6$s;",
        Lead_I_save, Lead_II_save, Lead_III_save,
        Lead_aVL_save, Lead_aVF_save, Lead_aVR_save);
Values_to_save.add(newLine);

A Toast appears with ECG values saved, but I cannot find the .csv anywhere.

I will welcome any suggestions. Thanks

Extrahumr
  • 3
  • 2

1 Answers1

0

You used a relative path (only a file name) and then your file lands in the apps private internal memory which is unreachable for other apps. Use a full path to external memory instead.

greenapps
  • 11,154
  • 2
  • 16
  • 19