iOS Question File weirdness when operating in dir.documents

Yuri Cinesi

Active Member
Licensed User
I have encountered an extremely strange behavior when using dir.documents.

I'm creating a file containing a string inside of dir.documents. Immediately after creating the file I check if it exists, and that returns true.
Later on, when trying to access the same file, it does not exist anymore.

The file is not deleted at any point in the code. None of this happens if the folder is dir.library instead.
I'm using a real iPhone 7.

This is the entirety of the code that references that file:

B4X:
File.WriteString(InternalsDirectory,"AccountType",btn.tag)
Log(File.Exists(InternalsDirectory,"AccountType"))


Then later on, once the user presses a button:

Log(File.Exists(InternalsDirectory,"AccountType"))
If (File.ReadString(InternalsDirectory,"AccountType") = "google") Then

InternalsDirectory is simply a variable I use to determine the directory I'm using, be it library or documents.
 

Yuri Cinesi

Active Member
Licensed User
The issue does not appear in a smaller project I'm afraid. I can post the full project, though I would prefer not doing so publicly.
 
Upvote 0

Yuri Cinesi

Active Member
Licensed User
New update: the bug is just...gone. Didn't change anything in the code, it just stopped happening.
I'd already tried reinstalling the application and cleaning the project, but it seems overwriting it with a different app (that had the same package name, I did it because I was doing some testing regarding firebaseauth) fixed it somehow.

Problem solved I suppose.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Was this on a real device or a simulator? There have been some issues reported about simulators not correctly handling the Documents directory.

- Colin.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Yuri,

It seems like the issue I described a few years ago (this was also on real devices)

 
Upvote 0
Top