Where is my file saved?

School Boy Error

Member
Licensed User
Longtime User
Hi, I've pinched a lot of code from the beginners book with regards to loading a csv into a panel (Chapter 12).

Got all that working how I want so that when a user clicks on a cell it changes the value depending on the value that is already there. The problem is I can't seem to save it!

The code that I have pinched is this:

B4X:
SaveTableToCSV(File.DirRootExternal, "english.csv")
StringUtils1.SaveCSV2(Dir, Filename, ",", list1, headers)

I've tried changing it to:

B4X:
SaveTableToCSV(File.DirInternal, "english.csv")
StringUtils1.SaveCSV2(Dir, Filename, ",", list1, headers)

It opens the files from File.dirassets but when I try and save there it tells me the file doesn't exist. I read somewhere that this folder is read only, so how then can I open a csv, edit it in my panel and then save my changes? Or where should I put it so I can do this?

Thanks
 

klaus

Expert
Licensed User
Longtime User
You should copy the file from DirAssets to another directory.
Something like this:
B4X:
If FirstTime = True AND File.Exists(File.DirRootExternal, "persons.csv") = False Then
  File.Copy(File.DirAssets, "persons.csv", File.DirRootExternal, "persons.csv")
End If
LoadTableFromCSV(File.DirRootExternal, "persons.csv", True)
File.DirRootExternal could be another directory like File.DirInternal.

Best regards.
 
Upvote 0

School Boy Error

Member
Licensed User
Longtime User
Thank you Klaus. What I don't understand at the moment is 1 - would that overwrite my original file (which is what I want it to do) and 2 - how do I do this in the testing phase?

I kind of get the idea that I need to be more specific for file paths when it is actually installed to my device but while I'm testing what do I do to write back to this file from my panel and save it?
 
Upvote 0

School Boy Error

Member
Licensed User
Longtime User
I'm getting there now, it's saved the file where I want it to, it's just only the headers. It doesn't seem to be populating the actual table again with any of the labels.....
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…