DirDefaultExternal Mystery

CSP

Member
Licensed User
Longtime User
I've searched high and low and maybe this has come up, but for some reason I can't figure this out...

The best way to describe it is to put it in steps:

- Successfully created the file l_data.dat on one device

- Same code, cannot create the file on other android device

- Same code, changed file name on working device, and it won't create the new file, yet the original file will still work but only on that device!

There are no full memory or permission issues etc.

Here is the code:
'Load data file
If File.Exists(File.DirDefaultExternal, "l_data.dat") = True Then
List1 = File.ReadList(File.DirDefaultExternal, "l_data.dat")
MaxNum = List1.Get(0)
MaxFields = List1.Get(1)
Else
MaxNum = 99
MaxFields = 6
End If

Then on Activity_Pause where the file is created:
List1.Clear
List1.Add(MaxNum)
List1.Add(MaxFields)
File.WriteList(File.DirDefaultExternal, "l_data.dat", List1)


Thanks for any help!
 

CSP

Member
Licensed User
Longtime User
The Mystery

Here is the mystery... With that same code, if I change the file name, it won't create the new file, save, or load from it. But if I change the file name back to l_data.dat, it will work only on my Droid. On my Devour, the code won't work at all, I'm assuming, until a data file is successfully created. I don't know why it created the file once and won't do it again on the same device, I've tried uninstalling the program, restarting to phone and factory resetting the phone to no use. What do you think should be done to remedy this? Thanks for your time in advance.
 
Upvote 0

CSP

Member
Licensed User
Longtime User
Mystery work-around

Alright, I'm not sure why, but if the file doesn't exist and it is called to be created on activity_pause then it won't be created for some reason. However, when I added the code to write to the file if it didn't exist in the first place, it seems to have fixed the problem.

Old non-working code:
'Load data file
If File.Exists(File.DirDefaultExternal, "l_data.dat") = True Then
List1 = File.ReadList(File.DirDefaultExternal, "l_data.dat")
MaxNum = List1.Get(0)
MaxFields = List1.Get(1)
Else
MaxNum = 99
MaxFields = 6
End If

Activity_Resume
List1.Clear
List1.Add(MaxNum)
List1.Add(MaxFields)
File.WriteList(File.DirDefaultExternal, "l_data.dat", List1)

New working code:
If File.Exists(File.DirDefaultExternal, "l_data.dat") = True Then
List1 = File.ReadList(File.DirDefaultExternal, "l_data.dat")
MaxNum = List1.Get(0)
MaxFields = List1.Get(1)
Else
MaxNum = 99
MaxFields = 6
List1.Clear
List1.Add(MaxNum)
List1.Add(MaxFields)
File.WriteList(File.DirDefaultExternal, "l_data.dat", List1)
End If

Activity_Resume
List1.Clear
List1.Add(MaxNum)
List1.Add(MaxFields)
File.WriteList(File.DirDefaultExternal, "l_data.dat", List1)

So essentially, by creating the file during the program when it is not found fixed the file from not being created on Activity_Pause.



Great program by the way Erel, many thanks from all of us VisualBasic and 'ol fashioned BASIC addicts for creating a new development platform for us to play on =)
 
Last edited:
Upvote 0
Top