B4J Question Save listview contents

ThRuST

Well-Known Member
Licensed User
Longtime User
I have tried to save the contents of a listview to a file without luck. I just get the message "Too many parameters" when I try

B4X:
    Dim SaveList As List
    SaveList.Initialize
   
    For i = 0 To Listview1.Items.Size - 1
        SaveList.AddAllAt(i,Listview1 & CRLF)   
    Next

File.WriteList(File.DirData,"mydata.txt", SaveList)

Appreciate any help with this.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
ok I tried this and it worked

B4X:
SaveList.Add(Listview1.Items.Get(i) & CRLF)

EDIT: & CRLF should be removed since it adds an empty space after each item.
There's therefore no meaning to keep it there.

However when saving I still get a "Too many parameters" error when I try to save with File.DirData.
Any custom path works but not File.DirData. Isn't that a valid path? I'm running Windows 10, and want a solution that works for both PC and Mac.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
if all you want is create a list from the contents of the listview, then

B4X:
SaveList.addAll(ListView1)

then you can save the list to file


[EDIT]
Actually, your solution is better
 
Last edited:
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Funny you found my post the second before I wrote you a message on Facebook. You should change name to the Flash :D
So do you have a solution for the File.DirData? it's supposed to point to the appdata/roaming folder. But it's not working!!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
DirData expects another parameter, like in my B4Xlauncher...

B4X:
File.DirData("B4X-Launcher")
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I was thinking that the project name was used automatically and added to the roaming folder!!!
Once you were in my shoes this is most embarrassing :eek::eek::eek:
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I updated my post #2 to point out misstakes I encountered, so that none walks in my footsteps of simple misstakes :confused:
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
File.DirData - A folder suitable for writing files. On non-Windows it is the same as File.DirApp. On Windows it points to the user data folder. For example:
B4X:
C:\Users\[user name]\AppData\Roaming\[AppName]

DirApp has different behavior according to O.S.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I noticed Erel pointed this out somewhere, but I still dunno where that is on my Mac I will have to investigate that. And also for Linux, Solaris, Ubuntu remains a mystery. But I'm not sure if Java virtual machine can run on those anyway, except PC, Mac and Linux as far as I know. That should make File.DirData the 'safest' path of storage
for all of these operating systems. If someone have experience from any of the other O/S please add your comment below, thanks.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Do a log(file.dirapp) to know the path
 
Upvote 0
Top