Android Question a List array question

FrancoisPG

Member
Licensed User
Longtime User
I am trying to write an array (Dim kKur(100) As kkSquare) of Type kkSquare (y As Int, x As Int, Tipe As Int, Waarde As Int, Index As Int) to a file to being able to restore the values when the application restart. In the Activity_Pause I have used the following:

File.WriteList (File.DirRootExternal, "SudStkKur.txt", kKur)

and in my Activity_Resume i have:

kKur = File.Readlist (File.DirRootExternal, "SudStkKur.txt")

but without any success. I gets an error telling me one is of type kkSquare and the the other is a list. If I change the read to Listkk as List on the left hand side, I can "see" my values under debug with the types of kkSquare. My question is how can I address these values,
1. something like Listkk(i).Tipe?
2. do I have to write kKur line for line and read it the same way?
3. can I give assign Listkk back to the array kKur?
 
Hi,
sorry mi ignorance, but what kind of type is kkSquare? Reading your post it doesn't seems to be a list, and File.WriteList needs a List for the last argument.
 
Upvote 0
Hi,
sorry mi ignorance, but what kind of type is kkSquare? Reading your post it doesn't seems to be a list, and File.WriteList needs a List for the last argument.
This is how I have declared kkSquare:
Type kkSquare (y As Int, x As Int, Tipe As Int, Waarde As Int, Index As Int)

In my File.WriteList I have used used an array (Dim kKur(100) As kkSquare), I thought it will be handled as a List? As I have said, when I use File.Readlist into a list, I can "see" all the values in Debug mode as if the list is of type kkSquare. I am not sure how to get these values back into my array kKur.
 
Upvote 0
File.WriteList creates a text file. It can only handle strings and numbers.

You should use either RandomAccessFile.WriteObject or (better) KeyValueStore class.
Hi Erel

Thank you for your response. I am sorry if I have not explained my problem clear enough (English is not my first language), but I have understood from the description of a List that "Basic4android automatically converts regular arrays to lists.". Does that mean that a multi dimentional array with only integer fields, as I have used it, is not a regular array and can't be converted to a List and write/read with WriteList and ReadList function?

Thank you
Francois
 
Upvote 0
Back
Top