- Home /
Android: StreamingAssets not Updated when APK Update
Hello there,
Well here is my problem: I use SQLite4Unity that requires my database to be placed in the StreamingAssets folder. This database is meant to be updated in the future with more content. Unfortunately, the files in this folder are not updated when I install an update of the app. I have to delete those files before installing the new version in order to get the new ones.
But how can I do that during the installation?
Can I include my files in my APK and overwrite the files in StreamingAssets? (nasty solution...)
If someone can help me with this, I'll raise my glass for him during the following aperitif (Hey, I know, but that's basically the best I can do to thnak you folks ;-) )
A+
Still not managed to find the solution. The "easy" solution is to make the user uninstall the app before installation, that means no update... this is something...
Still no answers to this question? I thought I wasn't the only one bothered by this restriction... Solution are suggested there (but not tested yet): http://answers.unity3d.com/questions/611534/on-android-how-can-i-update-files-in-the-strea$$anonymous$$g.html
Answer by m_vulicevic · May 09, 2017 at 05:21 AM
Hello, this is my first answer here.
For ages I've been trying to update my sqlite db for my game on game update, I even made a massive method that updates everything... Tonight, after analyzing SQLite4Unity connectDB method, I saw that it first checks if database is in Application.persistentDataPath, if not, it copies the database from streaming assets to persistent storage.
My solution to problem of updating database is simply... deleting it from persistentDataPath... I added "updated" PlayerPref to check value and see if it needs to run the code.
if (PlayerPrefs.GetInt("update") != up)
{
_connection.Close();
File.Delete(Application.persistentDataPath + "/your_db_name");
connectDB("your_db_name");
PlayerPrefs.SetInt("update", up);
}
Please, backup you db before testing this.
Hopefully someone will find this helpful.
This is good information, thanks! I can't check this (this question was asked last year) but it seems to be a good solution. Thanks again m_vulicevic!