Android Asset file is not updated when updating the application.

In my Android application, I have some configuration for the library in a text file named library.cfg. This file is in assets\libraryin my Android Studio project. (Both the application and the library are property, so I cannot divulge the details).

I install the application on our target device (which runs 2.3.4 Gingerbread, if relevant). The file is library.cfgdisplayed correctly.

I am editing the file library.cfgto add a new setting value.

Then I install the application again with the same signing config, but with the extension of the name / version code. The new APK includes new settings in the asset file.

If I just installed the application, the changes to library.cfgwill not be displayed by the copy of the file in /data/data/com.myapp.package/library/library.cfg. The file is the same as in the original installation.

If I uninstall the application and then install the second build of the application with the updated configuration file, it /data/data/com.myapp.package/library/library.cfgcontains the added values.

Why is the update not updated when updating the application, and not uninstalling / reinstalling? What do I need to do to make sure the file is updated during the update?

+4
source share
1 answer

Open the file with Context.getAssets()every time you start the application, when updating the application, first run it and after that check if the file has changed.

It seems that until you get access to the file, it is not extracted from apk in /data/data/<your-package>/

+3
source

All Articles