S sorex Expert Licensed User Longtime User Sep 18, 2017 #1 Hello, Is it normal that data written to file.dirDocuments is lost when you restart the app? using code as below shows that the file always vanishes while it was there before. with file.dirLibrary it seems to work fine tho. Code: Log(File.ListFiles(File.DirDocuments)) File.WriteString(File.DirDocuments,"test.txt","test") log("---") Log(File.ListFiles(File.DirDocuments)) Application_Start <B4IList: ( )> --- <B4IList: ( "test.txt" )>
Hello, Is it normal that data written to file.dirDocuments is lost when you restart the app? using code as below shows that the file always vanishes while it was there before. with file.dirLibrary it seems to work fine tho. Code: Log(File.ListFiles(File.DirDocuments)) File.WriteString(File.DirDocuments,"test.txt","test") log("---") Log(File.ListFiles(File.DirDocuments)) Application_Start <B4IList: ( )> --- <B4IList: ( "test.txt" )>
ilan Expert Licensed User Longtime User Sep 18, 2017 #2 Try to check if the file exists with file.exists Code: Log(file.exists(file.dirdocuments,"test.txt")) Upvote 0
Try to check if the file exists with file.exists Code: Log(file.exists(file.dirdocuments,"test.txt"))
S sorex Expert Licensed User Longtime User Sep 18, 2017 #3 that always returned false at a new run off the app. not after writing the file firsT. I've changed it to file.dirLibrary now wich always seems to work as expected. Upvote 0
that always returned false at a new run off the app. not after writing the file firsT. I've changed it to file.dirLibrary now wich always seems to work as expected.
ilan Expert Licensed User Longtime User Sep 18, 2017 #4 Weird. I am using dirdocuments and it works fine. Are u using a real phone for testing? Are u sure that u dont delete the file somewhere? Upvote 0
Weird. I am using dirdocuments and it works fine. Are u using a real phone for testing? Are u sure that u dont delete the file somewhere?
S sorex Expert Licensed User Longtime User Sep 18, 2017 #5 yes, it was on a real iphone 4 device that it was tested. the only file.delete line is commented. strange is that my game settings file was also written to the documents location and that file is still visible there. (altho I changed it to the library one a few versions ago) testing it now as new project with only that code works on my "home" iphone 4 (the other one was at work) Upvote 0
yes, it was on a real iphone 4 device that it was tested. the only file.delete line is commented. strange is that my game settings file was also written to the documents location and that file is still visible there. (altho I changed it to the library one a few versions ago) testing it now as new project with only that code works on my "home" iphone 4 (the other one was at work)
ilan Expert Licensed User Longtime User Sep 18, 2017 #6 sorex said: yes, it was on a real iphone 4 device that it was tested. the only file.delete line is commented. strange is that my game settings file was also written to the documents location and that file is still visible there. (altho I changed it to the library one a few versions ago) testing it now as new project with only that code works on my "home" iphone 4 (the other one was at work) Click to expand... i would check if there is a file.delete command because it doesnot make any sense. there is no reason that ios would delete any files that are stored in file.dirdocuments. i would go over the code again. Upvote 0
sorex said: yes, it was on a real iphone 4 device that it was tested. the only file.delete line is commented. strange is that my game settings file was also written to the documents location and that file is still visible there. (altho I changed it to the library one a few versions ago) testing it now as new project with only that code works on my "home" iphone 4 (the other one was at work) Click to expand... i would check if there is a file.delete command because it doesnot make any sense. there is no reason that ios would delete any files that are stored in file.dirdocuments. i would go over the code again.
B BjoernB Member Licensed User Longtime User Jan 8, 2020 #7 ilan said: there is no reason that ios would delete any files that are stored in file.dirdocuments. Click to expand... same problem, a few years later. the program runs fine on several iphones and pads, but on the iphone 11 it won't save the app settings. so definetly no wrong placed file.delete Upvote 0
ilan said: there is no reason that ios would delete any files that are stored in file.dirdocuments. Click to expand... same problem, a few years later. the program runs fine on several iphones and pads, but on the iphone 11 it won't save the app settings. so definetly no wrong placed file.delete
ilan Expert Licensed User Longtime User Jan 8, 2020 #8 BjoernB said: same problem, a few years later. the program runs fine on several iphones and pads, but on the iphone 11 it won't save the app settings. so definetly no wrong placed file.delete Click to expand... i also have an iphone 11 and everything works fine on my iphone 11. if you can make a simple example where you can reproduce the error then upload and i will check it on my iphone 11. btw are you using a real iphone or the simulator? Upvote 0
BjoernB said: same problem, a few years later. the program runs fine on several iphones and pads, but on the iphone 11 it won't save the app settings. so definetly no wrong placed file.delete Click to expand... i also have an iphone 11 and everything works fine on my iphone 11. if you can make a simple example where you can reproduce the error then upload and i will check it on my iphone 11. btw are you using a real iphone or the simulator?
B BjoernB Member Licensed User Longtime User Jan 9, 2020 #9 @ilan real iphone 11, switched from file.dirdocuments to file.dirlibrary, nothing changed. the iphone won't save any map data. the code saving it is: B4X: Dim mp as Map mp.Put("ip", "192.168.0.1") mp.Put("port", "9999") mp.Put("tnr", "1") File.WriteMap(File.DirLibrary, "sma.map", mp) don't know why, but the iphone 11 won't save this map. even after rotating the Phone, all settings are gone. reading it works that simple too: B4X: Dim mapdata as Map if File.Exists(File.DirLibrary, "sma.map") then mapdata = File.ReadMap("File.DirLibrary, "sma.map") End If Maybe it's an old compiler version? i'm using 5.3, how about you? Last edited: Jan 9, 2020 Upvote 0
@ilan real iphone 11, switched from file.dirdocuments to file.dirlibrary, nothing changed. the iphone won't save any map data. the code saving it is: B4X: Dim mp as Map mp.Put("ip", "192.168.0.1") mp.Put("port", "9999") mp.Put("tnr", "1") File.WriteMap(File.DirLibrary, "sma.map", mp) don't know why, but the iphone 11 won't save this map. even after rotating the Phone, all settings are gone. reading it works that simple too: B4X: Dim mapdata as Map if File.Exists(File.DirLibrary, "sma.map") then mapdata = File.ReadMap("File.DirLibrary, "sma.map") End If Maybe it's an old compiler version? i'm using 5.3, how about you?