checking if a txt file exists

merlin2049er

Well-Known Member
Licensed User
Longtime User
I've written some code I believe works? I'm not sure, I get different results with the emulator (vm with 2gb sd card) and with my phone.

The emulator can't seem to create the file, and it displays Msgbox("Cannot write on storage card.", "")

The phone will work.

Any ideas why the virtual machine (emulator ) with 2gb vm sd card won't create the file?
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Oh, I created the vm first. Then I went in and edited the vm and added 2gb external sd storage space to the vm.

Is that not acceptable?
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Here's the code I use to check if a file exist. Tried both True & False here.

B4X:
'create file first time if it doesn't exist  -- not working -- fix it
   If File.Exists(File.DirDefaultExternal,"button.txt") = True Then
   Map1.Initialize
   Map1.Put(0,Button1.Text )
   Map1.Put(1,Button2.Text )
        Map1.Put(2,Button3.Text )
   Map1.Put(3,Button4.Text )
   File.WriteMap(File.DirRootExternal, "button.txt", Map1)
   End If
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I don't understand.
You check if the file exists in File.DirDefaultExternal
If File.Exists(File.DirDefaultExternal,"button.txt") = True Then
but then you save on File.DirRootExternal
File.WriteMap(File.DirRootExternal, "button.txt", Map1)
Is this really what you want ?

Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…