-1

I have been having some trouble: my previous question here explains it all. I was trying to write to a file in the external storage which on my device is /data/media or /sdcard. The file (when you adb pull it with device on) one saves two lines of text and then gets overwritten but once you adb pull it again in recovery with /data mounted, all the logs appear.

I have tried mounting /data and then writing to the file but still no luck... Any help?

Community
  • 1
  • 1
arayray
  • 241
  • 6
  • 19

1 Answers1

-2

You code does not flush the BufferedWriter, so data are not written to log file but stays in the buffer.

How about replace code in try block of method 'writeToLog' of your code by following code?

    BufferedWriter bw = new BufferedWriter(new FileWriter(logFile, true))
    PrintWriter out = new PrintWriter(bw); 
    out.println(text);
    bw.flush() // Explicitly flushbufferedWriter
    out.close();
user207421
  • 305,947
  • 44
  • 307
  • 483
Fumu 7
  • 1,091
  • 1
  • 7
  • 8
  • Closing the `PrintWriter` automatically flushes it, which automatically flushes the `BufferedWriter.` – user207421 Sep 08 '14 at 01:46
  • That did not work, once there is two lines of text.. it overwrites both of them. But if I pull the file through adb, it shows all of the text entries though. – arayray Sep 08 '14 at 01:54