ı HAVE PROBLEM WİTH RANDOMACCESSFİLE.
First record is OK. But First record damged when second record added it. And first record separet 3 parts.
B4X:
Type PERSONEL (TamAd As String,User As String,Pass As String, Yetkilistesi As Map)
Public PERSONEL As List
Load code:
B4X:
Dim r As RandomAccessFile
r.Initialize(Main.AYAR.DirPersonel,Main.AYAR.FPersonel, False)
Log(r.Size)
If r.Size>0 Then
Dim res As Object=r.ReadB4XObject(0)
Main.PERSONEL= res
End If
r.Close
Save code:
B4X:
Dim r As RandomAccessFile
r.Initialize(Main.AYAR.DirPersonel,Main.AYAR.FPersonel, False)
r.WriteB4XObject(Main.PERSONEL, 0)
r.Close
You are writing at position 0 each time, it will write at the beginning of the file, overwriting what is already there with as much data as the write contains.
Using a RandomAccess file in this way means that you will need to keep an index of where each record is stored so that you can retrieve it. You should still consider using KVS2 it's a much simpler solution, or even SQLite directly if you want to search to retrieve the records..
I made a foolish mistake.I don't know what it is. I made a simple example, but Its worked.
I erased the code and rewritten it.
Sometimes I must rewrite code more simple.