Android Question Write Log to File

FabioG

Active Member
Licensed User
Longtime User
Hello,

use this code to write log events of my app on file

this works well thus special adds a new row at the end of file

is there a way to affiungere new riche beginning of the file?
in order to have the latest events at the top and not at the end?

thanks
Fabio


B4X:
Sub LogWrite(EventsLog As String)
  
    Log(EventsLog)
  
    Dim TextWriter1 As TextWriter
    TextWriter1.Initialize(File.OpenOutput(File.DirInternal, "MyLog.log", True))
    TextWriter1.WriteLine("- " & EventsLog)
    TextWriter1.Close
  
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Alternatively you also can write the log to a sqlite-db and then, when needed, you can show only the last line. Or even show all entries in reverse order...
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Alternatively you also can write the log to a sqlite-db and then, when needed, you can show only the last line. Or even show all entries in reverse order...

This, I was wondering if you could just present the information from the file in a different order. Using a DB as an intermediary step could be good, or possibly a list, listview, scrollview or some other similar container and present the data in reverse order as it were or get a few lines at a time, keep a placeholder and page through the file in reverse order.
 
Upvote 0
Top