Android Question Saving Default String Data Containing CRLF

RichardN

Well-Known Member
Licensed User
Longtime User
Since before KVS was born I have saved default field data by assigning each field to a List element then saving to file with File.WriteList()

Apparently that does not work when the string data contains CRLF because the line are divided up and added as individual list elements. So I gave KVS a try only to discover exactly the same thing happens. I also tried String.Replace(CRLF,"|") to change the CRLF into a handy substitute to decode on retrieval but that does not work either. (Maybe I'm not hitting the right string element?)

Is there a quick and easy way to save default string values containing CRLF without it's own dedicated file for read/write?
 

agraham

Expert
Licensed User
Longtime User
I also tried String.Replace(CRLF,"|") to change the CRLF into a handy substitute to decode on retrieval
That should work. Have you overlooked that Strings are immutable and String.Replace needs to be assigned?
B4X:
Dim s as String

s = "fred " & CRLF & "Jim"
s = s.Replace(CRLF, "|")
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
@agraham... Yes I have used that method extensively for reading and writing text to Sqlite. I'm all done banging my head against the wall for today. Will take another look tomorrow.
 
Upvote 0

emexes

Expert
Licensed User
Also CRLF is really just LF, so if your string actually contains Chr$(13) + Chr$(10) then after you String.Replace(CRLF,"|") it will instead contain Chr$(13) + "|"

That sounded much simpler in my head before I wrote it down. šŸ™ƒ
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
Too much screen time yesterday!

KVS works fine after some familiarisation. The KVS library situation is rather confusing though!....

KVS2 is deprecated whilst KVS is the most up to date ????? A situation made much worse by the fact that the comments in the library panel only become visible once the library is loaded so are easily missed. When loading a library you scroll down to it..... check the box and it immediately moves out of sight to the top of the list so the comments are not immediately evident.
 
Upvote 0
Top