Android Question b4x not willing to create file

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I´m getting the below error:

B4X:
java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/messages/headers: open failed: ENOENT (No such file or directory)

...after having fun changing a bunch of stuff in my code, and I really can´t see what I´m doing wrong here. This is the trigger:

B4X:
RAF.Initialize2((File.DirDefaultExternal & "/" & usernametmp & "/messages/"),"headers", False,False)

I even tried running the line when the apps first activity appears, to make sure that it´s not somehow conflicting with stuff going on later, but with the same result.
I´m using the memu emulator, and as far as I can tell, it has not updated itself to a newer version that could cause this to happen. Also, write permissions on dirdefaultexternal are showing as True. The /usernametmp/messages/headers path and file don´t exist yet, but before I would sit and delete it all the time, where it´d be automatically created when debugging the app.
EDIT: Just tried creating the file with es file explorer and now I´m not getting the error. So the question is why initialize2 won´t create the file for me anymore as it used to?

FYI, b4a creates the b4a.example/files/ dir upon launch, so indeed the device CAN be written to.

Any idea what I´m doing wrong?
 
Last edited:

kostefar

Active Member
Licensed User
Longtime User
Android 6? Change the target sdk to <23.

It already was all the time:

<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>

Thanks anyway.

Ok, found the magic trick. Really not sure why I suddenly need to do this:

B4X:
File.MakeDir (File.DirDefaultExternal,usernametmp & "/messages/" )

Not a big deal to have that extra line, just superweird cause I know I never had it there before. And, obviously I only need to run that once..
 
Last edited:
Upvote 0
Top