0
votes

Is there a way to see if assets file changed between application reinstall in Android? Something like md5 or timestamp on whole assets folder (afaik assets are just a zipped file, so maybe it's possible to check just this file for changes?)?

We have an application in which we store configuration xml's in assets folder, then parse them to binary form. As the application is still in development xmls change sometimes. I'd like to be able to automatically determine that assets changed, so I can 'reload' xmls to binary form. It is always the case, that we have the same amount of xml files which change their content a little so seeing if file list changed is not enough.

I know it would be possible to keep a version number, but if possible, I would like to avoid it because it is error prone and would require some discipline from every programmer.

EDIT

Found this answer now: Android assets timestamp

As this shows assets timestamp may not be a good idea because it does not reflect asset files timestamp, but rather build time.

1

1 Answers

0
votes

Take the hash of each file and store along with filename in shared preferences or a file. Also store the current versionCode. On startup, compare the versionCode of the app with the one on disk, and if it has changed, calculate the hashes of your assets and compare with ones on disk.