B4J Question B4J jRandomAccessFile - How to Clear ?

focus330

Member
Licensed User
Hi

I'm trying to clear all contents of a RandomAccessFile but I don't understand how to do it.
I try simply deleting file, but, until the app is open, there is no permission to do it, also closing the raf before delete.

I tried also with javaobjects with method 'setLenght' but isn't recognized.

Is it possible to clear a raf ?

Thanks for suggestions.
 

focus330

Member
Licensed User
Well,

I don't know what happened yesterday.
Also exiting from b4j and restarting it, in debugging mode and also in release mode, the delete instruction was always False
But with explorer , with the app closed, I could delete the fiie. Of course, with the app opened, I coudn't do it. Permissions were OK.

Today, after the restart of the PC 'file.delete' works correctly.
Then it seems that one istance of raf.initialize remains attached.
The same, it is strange for me that yesterday with explorer I could delete the file and with code I didn't.


Probably an occasional event that I don't understand. To be sure, I'll release the app to the user writing an empty list instead of deleting file.
 

focus330

Member
Licensed User
My code now is
B4X:
Dim Listazz as list
Listazz.initialize
raf.close
EsitoBool = File.Delete(File.DirData("MYApp"),"log_apk")
        If EsitoBool = False Then
            File.WriteList(File.DirData("MYApp"),"log_apk",Listazz)
        Else
            raf.Initialize(File.DirData("MYApp"),"log_apk",False)
        End If
 
Top