Android Question How to check if a raf contains a valid B4X object

Branko Milosevic

Active Member
Licensed User
I am looking to test a file for a valid B4X object before reading it. My best effort to prevent my app from showing as an option to handle files in Open With... dialogs wasn't very successful so I want my app to reject any file that contains data created by other applications if the user chooses to open it with my app.
At the moment I can't read the file without crashing.
Thanks in advance for ideas...
 

Branko Milosevic

Active Member
Licensed User
This is what I have now
B4X:
Dim Inp As InputStream  = File.OpenInput(ContentDir , strUri)
Dim Out As OutputStream = File.OpenOutput(File.DirRootExternal&"/MyDir", "MyFile", False)

' Check if input stream is a valid B4X object

                File.copy2(Inp, Out)
            
                Inp.Close
                Out.Close
Before I copy2 I would like to check if the input stream file contains a valid B4X object.
 
Upvote 0

Branko Milosevic

Active Member
Licensed User
That's right, a list is written to a file with writeB4xobject. What to look for in the file at 4 byte mark? What's the format of the file?
I now try to read the B4x object and try-catch exception but it doesn't look right. It's like electrician shorting the circuit to find which breaker in the breaker box the circuit is hooked up to. :)
 
Last edited:
Upvote 0

Branko Milosevic

Active Member
Licensed User
Unfortunately i originally didn't plan to have file sharing feature and both iOS and Android apps are released. So I can't change format of the file now but was hoping I could extract some unique features of the list object saved in the file.
Also I am attempting to prevent app from reading bitmaps and other file types that the user may click on in an Open With... dialog when my app shows as available to handle the file (but should not be there).
 
Upvote 0
Top