SQLite4Unity3d icon indicating copy to clipboard operation
SQLite4Unity3d copied to clipboard

[Android] How to update new sqlite in StreamingAssets folder ?

Open ttpro1995 opened this issue 9 years ago • 1 comments

I going to ship my product with pre-defined database in Assets/StreamingAssets. However, when I update application with new database (install the update from App store, but not delete and reinstall), the pre-defined sqlite is not update. (it still use old database). How can I get my data updated? (without delete and reinstall app on phone)

Thank you

ttpro1995 avatar Mar 07 '16 06:03 ttpro1995

I think you can keep your sqlite db in the Resources folder and when you open the App for the first time, you will copy it to Application.persistentDataPath.

Something like that:

TextAsset sqdbTextAsset = Resources.Load("sqlite_folder_name/your_database.sqdb") as TextAsset; File.WriteAllBytes(Application.persistentDataPath + "/your_database.sqdb", sqdbTextAsset.bytes);

PS.: the file need to be named with .txt extension, in order to be loaded as TextAsset: your_database.sqdb.txt

sandolkakos avatar Mar 07 '16 19:03 sandolkakos