Hi to everybody:
I'working with RandomAccessFiles and WriteEncryptedObject / ReadEncryptedObject and i have this error:
And this is my code:
I want to save a Map and one key contains an array of 20 elements (int).
Can this be the cause? How do I fix it?
What i'm doing wrong??
Thanks
I'working with RandomAccessFiles and WriteEncryptedObject / ReadEncryptedObject and i have this error:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
ags_config_save (B4A line: 302)
Raf2.WriteEncryptedObject(Config2, "secret", Raf.CurrentPosition)
java.lang.NullPointerException
at com.ags.agsmtilitemobile.ags._config_save(ags.java:639)
at com.ags.agsmtilitemobile.main._jobdone(main.java:737)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:962)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
And this is my code:
B4X:
Sub Process_Globals
Dim ColorSondas() As Int = Array As Int(0xFF0000FF, 0xFF00C000, 0xFF00C0C0, 0xFFC0C000, 0xFFC04000, 0xFFC000C0, 0xFFC00000, 0xFFFF8000, 0xFFFF0000, 0xFF80FFFF, 0xFF808080, 0xFF808000, 0xFFFFFF00, 0xFF8080FF, 0xFFFF80FF, 0xFF80FF80, 0xFF8FBC8B, 0xFFFF00FF, 0xFF483D8B, 0xFF6495ED)
....
End Sub
Sub Config_Save As Boolean
Try
File.WriteMap(File.DirInternal, "Config.txt", Config)
Dim Config2 As Map
Config2.Initialize
If File.Exists(DataDir, "Config.dat") AND File.Size(DataDir, "Config.dat") > 0 Then Then
Dim Raf As RandomAccessFile
Raf.Initialize(DataDir, "Config.dat", False)
Config2 = Raf.ReadEncryptedObject("agsystem", Raf.CurrentPosition)
Raf.Close
End If
For Each Key As String In Config.Keys
Config2.Put(Key, Config.Get(Key))
Next
Dim Raf2 As RandomAccessFile
Raf2.Initialize(DataDir, "Config.dat", False)
'The next sentence is the cause of the error
Raf2.WriteEncryptedObject(Config2, "secret", Raf.CurrentPosition)
Raf2.Close
Return True
Catch
Log(LastException)
Return False
End Try
End Sub
I want to save a Map and one key contains an array of 20 elements (int).
Can this be the cause? How do I fix it?
What i'm doing wrong??
Thanks
Last edited: