this is my sub that i think takes time to read and decode the file and makes me problems
readEncFile:
Sub readEncFile(dirName As String,fileName As String) As String
Dim data() As Byte
Dim Dokumentdatei As RandomAccessFile
Dokumentdatei.Initialize(dirName,fileName,False)
data=Dokumentdatei.ReadB4XObject(0)
Dokumentdatei.Close
data=encr.Decrypt(data,"something")
return bc.StringFromBytes(data,"utf8")
End Sub
when the file is small it works well but with one of files which is 7kb it won't
i want to wait for this sub to be complete so i used (wait for) this way
something:
Sub getText As ResumableSub
Dim temp As String
wait for (readEncFile(File.DirDefaultExternal,"rest.pol")) complete (temp As String)
Return temp
End Sub
i'm confused how to use wait for with this. readEncFile sub returns a string. how can i wait for sub to read and decode whole file
Remember: code with File.DirDefaultExternal = broken code.
You cannot use Wait For with blocking methods. I guess that the slow part is the decryption. The serialization can be done asynchronously with B4XSerializator.
Remember: code with File.DirDefaultExternal = broken code.
You cannot use Wait For with blocking methods. I guess that the slow part is the decryption. The serialization can be done asynchronously with B4XSerializator.
yes the slow part is decryption.on my phone it takes almost 5 seconds and it's too long for me so i decided to decrypt the file already to be ready in memory until when i need it