Android Question Saving a list with name and MAC adresses for BT

Amateurtje

Member
Licensed User
Longtime User
Hello, I am very new with B4A and run into a problem with saving a list.I want to save different BT connections in a list.(to show in listview)

B4X:
    Type NameAndMac (Name As String, Mac As String)
dim NM as nameandmac
I save with:
B4X:
templist.Add(connectedDevice)
File.WriteList(File.DirRootExternal,"MyList.txt",templist)

I would like to read with:
B4X:
If File.Exists(File.DirRootExternal, "MyList.txt") Then
templist = File.ReadList(File.DirRootExternal,"MyList.txt")

  For i = 0 To templist.Size - 1
 Dim nmtemp As NameAndMac
   nmtemp = templist.Get(i)
   lstUsedDevices.AddSingleLine2(nmtemp.Name,nmtemp.Mac)
  Next
 End If

Problem:
When reading the saved templist the elementdata looks like:
0=[IsInitialized=false, Mac=20:13:10:15:43:01, Name=HC-05
1=]

I thought there was a crlf in the name or the line was too long so I substitute the name with a "1".. This did not help.. How can it be that it is divided into 2 elements and I cna not read it back into the list??
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
in the tutorial i see nothing about saving a file, only sending and RAF is not recognised by my BA....the ranodom accesfile library is activated (2.32)...
 
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
found it. sorry, i am very new and some things I am not used to..
I forgot to define
Dim raf As RandomAccessFile
and I have to get used to initialising...:) it will come to me..please be patient..

Thanks for the help!
 
Upvote 0
Top