Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The code that saves data only stores a text line containing both number separates by a tab. When your code reads the file, you read the entire line, trying to parse the text, that obviously is unparseable (has a tab).</p> <p>You should iterate your arrays writing each line. Then, the read method should split the readed string and parse each substring separately.</p> <p>Regards.</p> <p>Lets try to explain what I would do [not compiled]:</p> <pre><code>File sdCard = Environment.getExternalStorageDirectory(); File directory = new File (sdCard, "MyFiles"); directory.mkdirs(); File file = new File(directory, filename); FileOutputStream fos; try { fos = new FileOutputStream(file); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); //I assume mydata and myweight are both List&lt;Double&gt;... with same size for(int i = 0; i &lt; mydata.size(); i++){ bw.write(mydata.get(i)+"\t"+myweight.get(i)+"\n"); } bw.flush(); bw.close(); } catch (IOException e2) { e2.printStackTrace(); }//catch </code></pre> <p>...</p> <pre><code>File sdCard = Environment.getExternalStorageDirectory(); File directory = new File (sdCard, "MyFiles"); File file = new File(directory, filename); String s; FileInputStream fis; try { fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); do { s = br.readLine(); if (s != null) { String[] splitLine = s.split("\\t"); data.add(Double.parseDouble(splitLine[0])); weight.add(Double.parseDouble(splitLine[1])); } } while (s != null); } catch (IOException e) { e.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload