i am trying to read an old settings ini file i created years ago, the code below is lifted directly from the B4A program i used but it doesn't seem to work now using the latest B4A:
i get the following error in the log:
Does anyone have any ideas? thanks
B4X:
Dim raf As RandomAccessFile
Dim ini As Map
ini.Initialize
raf.Initialize(File.DirInternal, "Settings.ini", True)
ini = raf.readEncryptedObject("Password1", raf.CurrentPosition)
Log("INI Version: " & ini.Get(1))
Log("Use Deg/Min/Sec instead of Decimal: " & ini.Get(2))
Log("Display a Gyro: " & ini.Get(3))
Log("Display ROT: " & ini.Get(4))
Log("Device ID: " & ini.Get(5))
Log("Rate of Turn Step 1: " & ini.Get(6))
Log("Rate of Turn Step 2: " & ini.Get(7))
Log("Rate of Turn Step 3: " & ini.Get(8))
Log("Rate of Turn Step 4: " & ini.Get(9))
Log("Bluetooth Device Name: " & ini.Get(10))
Log("Bluetooth Device MAC: " & ini.Get(11))
Log("Wifi SSID: " & ini.Get(12))
Log("Wifi Port: " & ini.Get(13))
Log("Wifi IP: " & ini.Get(14))
Log("Demo Mode (checked): " & ini.Get(15))
Log("Name: " & ini.Get(16))
raf.Close
i get the following error in the log:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 44 (Main)
java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Buffer.java:493)
at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:555)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadInt(RandomAccessFile.java:154)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:423)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadEncryptedObject(RandomAccessFile.java:420)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at lish.soft.inifile.main._rini_file(main.java:401)
at lish.soft.inifile.main._activity_create(main.java:393)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at lish.soft.inifile.main.afterFirstLayout(main.java:105)
at lish.soft.inifile.main.access$000(main.java:17)
at lish.soft.inifile.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
** Activity (main) Resume **
Does anyone have any ideas? thanks