Note that there are some explanatory texts on larger screens.

plurals
  1. POFileoutputStream / bufferreader
    primarykey
    data
    text
    <p>I have an equation which result is displayed in a TextView. Then i have another TextView which act like a History. This History i want to save with a file and the file should be reloaded after the app will be killed an restarted.</p> <p>Whats i dont understand is that the second TextView which is the View that i will save is displayed wierd stuff after starting the app</p> <p>Thise line over and over again.</p> <pre><code>android.widget.TextView{41852c0 VFED.VCL ..... ID32,316-419,351 #7f09000a app:id/tvHistory} </code></pre> <p>My own Code:</p> <pre><code>final static String FILENAME = "marks.txt"; mNotenHistory=(TextView)findViewById(R.id.tVhistory); mNotenHistory.setMovementMethod(new ScrollingMovementMethod()); private void loadTextfromFile() { File f = new File(getFilesDir(),FILENAME); try { BufferedReader br = new BufferedReader(new FileReader(f)); String line; try { while ((line = br.readLine()) != null) { mNotenHistory.setText(line+"\n"+mNotenHistory.getText()); } br.close(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { e.printStackTrace(); } } @Override public void onClick(View view) { [...] mNotenHistory.setText(mNotenHistory.getText() + "\n" + string_note); String noten_history_string = String.valueOf(mNotenHistory); try { FileOutputStream fo = openFileOutput(FILENAME, Context.MODE_APPEND); fo.write(noten_history_string.getBytes()); fo.write("\n".getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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