How to save DB changes

Shay

Well-Known Member
Licensed User
Longtime User
Hi

I am using this when my app is loading
File.Copy(File.DirAssets,"data.db",File.DirDefaultExternal,"data.db")
(also tried on firstTime only )

inside my code I have update:
MainMenu.SQL1.ExecNonQuery("UPDATE Table_1 SET Name='" & TextBox1.Text & "' Where Id='1'")

it is updaing the table, since i am calling read again, and I can see the data changed

but when I exist the app and enter again, I am getting my old data
 

hdtvirl

Active Member
Licensed User
Longtime User
This might be a stupid question.

Shay are you over writing your database when you restart your application.

File.Copy(File.DirAssets,"data.db",File.DirDefault External,"data.db")

if your app is using the database in DirDefault External, are you writing it back to File.DirAssets when you close your app.

Regards

BOB
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I tried also to copy the DB only on firsttime

I just tried what ou suggested - on exit
File.Copy(File.DirDefaultExternal,"data.db",File.DirAssets,"data.db")
but getting error that no such directory for the dirassets

what is the best way to copy (from where to where) DB file and then make sure it is saved?
 
Upvote 0

hdtvirl

Active Member
Licensed User
Longtime User
Shay, did you cut and paste this line of code out of your app.

File.Copy(File.DirDefaultExternal,"data.db",File.D irAssets,"data.db")
=
if so there is a space in D irAssets this might be your problem.

Also copy the database to somewhere you can upload it back to your development PC and using a sqlite browser see if the changes you made are visible on your PC.

BOB
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
the space, seems to be the forum problem

what is the best way to copy from and to the DB?
I saw in the help that you cannot copy to asset
so how do I fix my problem?
 
Upvote 0
Top