Il mio codice è:Impossibile aggiungere testo in un file
if(myfile.exists()) {
try {
FileOutputStream fOut = new FileOutputStream(myfile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
for (LatLng item : markerArrayList) {
myOutWriter.append(item.toString());
}
myOutWriter.append("\n\n");
myOutWriter.close();
fOut.close();
Toast.makeText(getBaseContext(), "Done writing ", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
Quando uso myOutWriter.append
, ciò che realmente accade è che ogni volta che sto scrivendo al file, sovrascrive il contenuto precedente.
Non c'è: http://developer.android.com/reference/java/io/OutputStreamWriter.html – vicolored