IatroJordan
Lurker
Hi, I am trying to write a string which is the output of my counter into a text file. I tried using the android coding from the tutorial but it still doesn't work. Can anyone advice me on this? My text file is inside the directory src/main/assets.
- public void saveText(){
int seconds;
FileOutputStream outputStream;
String saveText;
long elapsedMillis = SystemClock.elapsedRealtime() - mChronometer.getBase();
seconds = (int) (elapsedMillis / 1000);
try {
outputStream = openFileOutput("logs.txt", MODE_APPEND);
saveText = String.valueOf(seconds);
outputStream.write(saveText.getBytes());
outputStream.close();
Toast.makeText(this, saveText, Toast.LENGTH_LONG).show();
} catch (Throwable t){
Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show();
}
}