Does an upgrade from the market overwrite the database?

netchicken

Active Member
Licensed User
Longtime User
I have an sqlite db in my app and wonder if, when I post an upgrade in the market for it, does that upgrade overwrite the DB on the phone with the DB in your updated program?

If so that would return the app to its empty version and lose any changes.

Can this be prevented?
 

Brad

Active Member
Licensed User
Longtime User
If the db is in the asset directory then yes, it will be overwritten. If it's elsewhere then it will not be overwritten.
 
Upvote 0

netchicken

Active Member
Licensed User
Longtime User
Pre compiling its in the Objects folder and in the code its...

B4X:
If File.Exists(File.DirInternal,"shopping.sql") = False Then
File.Copy(File.DirAssets,"shopping.sql",File.DirInternal,"shopping.sql")
End If

I don't know where it is when its installed on the phone but apparently from the code its in the Assett.

What do others do about it? It must be a common issue surely? Every time people down load a new version they can't get all their data wiped.
 
Last edited:
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
I had originally typed more but after re-reading, I don't think you have anything to worry about.

You are only copying the included (asset) file if it does not already exist in the DirInternal folder. Since it should already exist if the user is updating, the file should not be overwritten.

My app stores settings in DirInternal (and also saves a copy on the SD card) and installing updates to my app does not replace the user's settings. Granted, I am not including a settings file in the assets folder, but again, so long as your code only copies that if it does not already exist in the DirInternal folder, then I don't see a problem.

I assume your app "uses" the database stored in File.DirInternal, not the one in the assets folder.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…