Android Question SQLite not updating after exit program

Bernard Harris

Member
Licensed User
Longtime User
Hello, I have an Android app that I created a year ago. It does updates to a SQLite database installed with the app. It worked fine on Android 10 but with Android 12 when we make changes and then exit the app the changes are not saved. When we restart the app it starts with the data just like it was originally installed. Is there something special that needs to be done to save all changes before exiting the app now?
 

Bernard Harris

Member
Licensed User
Longtime User
Sorry so late in getting back to your quick response. :(
I am only copying the .db file. What other files are there to copy along with the .db file?

This is the statement I am using to get the database to the phone:

File.Copy(File.DirAssets, "inventory.db", File.DirInternal, "inventory.db")
 
Upvote 0

Bernard Harris

Member
Licensed User
Longtime User
With the latest update of the app I also created Indexes in SQLite. Could that be why it's not updating also? And are the indexes stored separately and they have to be copied?
 
Upvote 0

Bernard Harris

Member
Licensed User
Longtime User
I believe you hit on my problem Erel. I had the If condition in there to check if it exists and if not then copy the file. I commented this condition out and this must be copying from the install back in and causing it to reset each restart. I will put that back in. It just hit me this morning that this might be the issue! Sorry for the dumb question when it's my own fault. BUT thanks for your help!

Can I ask another question? What is the best method to copy this db back to the installed desktop? I want to retrieve what has been entered here. Thanks again! :)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
What is the best method to copy this db back to the installed desktop?
Normally, you need to post a different question in a different thread, but since this has been answered hundreds of times:
The answer to your question is in this thread:
 
Last edited:
Upvote 0
Top