K Kamac Active Member Licensed User Longtime User Sep 13, 2011 #1 I've encountered some problems while reading a list. Here's how i save a list: B4X: all.Add(Moneyy) File.WriteString(File.DirRootExternal,"save.txt",all) and here's how i try to read it to a variable: B4X: Dim lall As List lall = File.ReadList(File.DirRootExternal,"save.txt") Moneyy = lall.Get(0) B4X: java.lang.NumberFormatException and it's pointing at this line: B4X: Moneyy = lall.Get(0) What's going on
I've encountered some problems while reading a list. Here's how i save a list: B4X: all.Add(Moneyy) File.WriteString(File.DirRootExternal,"save.txt",all) and here's how i try to read it to a variable: B4X: Dim lall As List lall = File.ReadList(File.DirRootExternal,"save.txt") Moneyy = lall.Get(0) B4X: java.lang.NumberFormatException and it's pointing at this line: B4X: Moneyy = lall.Get(0) What's going on
H hdtvirl Active Member Licensed User Longtime User Sep 13, 2011 #2 FormatError Your answer might in here http://www.b4x.com/forum/basic4android-updates-questions/11415-how-read-number-text-file-2.html regards BOB Upvote 0
FormatError Your answer might in here http://www.b4x.com/forum/basic4android-updates-questions/11415-how-read-number-text-file-2.html regards BOB
thedesolatesoul Expert Licensed User Longtime User Sep 13, 2011 #3 You are writing a string and reading a list? What are you writing, does it contain numeric data? If you want it to be a string then Dim Moneyy as a string. EDIT: Actually ReadList returns strings. Have you Dimmed Moneyy as Int? Do a log(lall.Get(0)) Last edited: Sep 13, 2011 Upvote 0
You are writing a string and reading a list? What are you writing, does it contain numeric data? If you want it to be a string then Dim Moneyy as a string. EDIT: Actually ReadList returns strings. Have you Dimmed Moneyy as Int? Do a log(lall.Get(0))
klaus Expert Licensed User Longtime User Sep 13, 2011 #4 To save the list you should use: B4X: File.WriteList(File.DirRootExternal,"save.txt",all) Best regards. Upvote 0
To save the list you should use: B4X: File.WriteList(File.DirRootExternal,"save.txt",all) Best regards.
K Kamac Active Member Licensed User Longtime User Sep 13, 2011 #5 Actually ReadList returns strings. Have you Dimmed Moneyy as Int? Click to expand... Yep. Moneyy is dimmed as int... But how can i change from string which holds only number to Int? @EDIT lall.get(0) returns this: B4X: (ArrayList) [200,other numbers i'm saving separated by ,] That's dumb :O It should return only Moneyy value which is 200. @EDIT2 Fail.... As Klaus said, i used WriteString instead of List... Last edited: Sep 13, 2011 Upvote 0
Actually ReadList returns strings. Have you Dimmed Moneyy as Int? Click to expand... Yep. Moneyy is dimmed as int... But how can i change from string which holds only number to Int? @EDIT lall.get(0) returns this: B4X: (ArrayList) [200,other numbers i'm saving separated by ,] That's dumb :O It should return only Moneyy value which is 200. @EDIT2 Fail.... As Klaus said, i used WriteString instead of List...