RandomAccessFile File deleted

gmachacek

Member
Licensed User
Longtime User
Hallo, I do have following problem.
I save my App settings in a file as follows ...

Sub btnSave_Click

'writing the object
Dim raf As RandomAccessFile
Main.thesettings.Language = pdnLanguage.SelectedIndex
Main.thesettings.Show = pdnShow.SelectedIndex
Main.TheSettings.UserName = txtUsername.Text
Main.TheSettings.ClrPassword = txtPassword.Text
Dim Bconv As ByteConverter
Dim data(0) As Byte
Dim md As MessageDigest
data = Bconv.StringToBytes(txtPassword.Text, "UTF8")
data = md.GetMessageDigest(data, "MD5")
Main.TheSettings.Password = Bconv.HexFromBytes(data)
Main.TheSettings.Client = txtClient.Text
Main.TheSettings.Imei = lblImei.text
Main.TheSettings.TxtLanguage = pdnLanguage.SelectedItem
If File.Exists(File.DirRootExternal, "EcoObjSec.dat") Then
raf.Initialize(File.DirRootExternal, "EcoObjSec.dat",False)
raf.WriteEncryptedObject(Main.TheSettings, "settings", 0)
raf.Close
End If

End Sub

... this works and if I end the App and restart settings are available.

But if I start the Task manager and do clear memory the settings are gone if I
restart the app.

I tried as path ...
File.DirRootExternal
File.DirDefaultExternal

I am using Samsung Galaxy S II

Could anybody help thx in advance
Georg
 

gmachacek

Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
Type SetStruct (Language As Int ,UserName As String, Password As String, ClrPassword As String, Client As String, Imei As String, Show As Int, TxtLanguage As String)
Dim TheSettings As SetStruct
End Sub

Sub Activity_Create(FirstTime As Boolean)
......
......
If File.Exists(File.DirRootExternal, "EcoObjSec.dat") Then
'reading the object    
Dim raf As RandomAccessFile    
raf.Initialize(File.DirRootExternal, "EcoObjSec.dat", False)    
TheSettings = raf.ReadEncryptedObject("settings",0)    
raf.Close
End If
.......
.......
End Sub
It didn't work with both folder.

Thx
Georg
 
Last edited by a moderator:
Upvote 0

gmachacek

Member
Licensed User
Longtime User
Hallo Erel,
I did a mistake.
But never the less you helped me to find out at the and of the day.
Thx
Georg
 
Upvote 0
Top