iOS Question Where to save a file that does not get deleted?

John Woodsmall

Active Member
Licensed User
Longtime User
This is important as the history.csv will contain birth data that has been entered from before.
 
Last edited:

John Woodsmall

Active Member
Licensed User
Longtime User
I save a table to the File.DirLibrary
B4X:
Table4.SaveTableToCSV(File.DirLibrary, "History.csv")
(I have put my default history.csv file there from File.DirAssets on startup if it is not there from before)
B4X:
File.Copy(File.DirAssets,"History.csv" ,File.DirLibrary,"History.csv")

And I update it there...However if I remove the app from the device and replace it with a new version
That which I have saved there is missing?

Where can I save something that stays with the phone?(also when I update the app the table I have written is removed)
This is important as the history.csv will contain birth data that has been entered from before.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are two different scenarios:
1. User updates the app from the app store or any other way => the files will not be deleted.
2. User uninstalls your app => all files will be deleted.

The only way to store persistent data that is kept after uninstalls is with the keychain. I don't think that it is relevant here.
Check Phone.KeyChainPut and KeyChainGet.
 
Upvote 0

John Woodsmall

Active Member
Licensed User
Longtime User
ok

1.) I have the app running on my phone and I add some values to my table and then I save it
to the file.File.DirLibrary, "History.csv" above.
2.) In b4i (latest) I run tools>build server>release app.
all goes well and it is downloaded to the phone.
3.) I open the app and the values that I have saved (above) are gone and the default values
have been copied over.

So, does that mean that only if the app is downloaded from itunes.connect are the files protected?
and or

This keychain thing is the only way to have a protected file on the phone?
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
ok

1.) I have the app running on my phone and I add some values to my table and then I save it
to the file.File.DirLibrary, "History.csv" above.
2.) In b4i (latest) I run tools>build server>release app.
all goes well and it is downloaded to the phone.
3.) I open the app and the values that I have saved (above) are gone and the default values
have been copied over.

So, does that mean that only if the app is downloaded from itunes.connect are the files protected?
and or

This keychain thing is the only way to have a protected file on the phone?

I use keychain for a similar task. works perfect. BTW as Erel said probably you are not doing:
B4X:
    If File.Exists(File.DirLibrary,"user.sql") = False Then
        File.Copy(File.DirAssets,"user.sql",File.DirLibrary,"user.sql")
    End If
if files exists you must not copy the file again. if you do it will overwrite.
 
Upvote 0
Top