In my Android application, I have some configuration for a library in a text file called library.cfg
. This file lives in assets\library
in my Android Studio project. (Both the application and library are proprietary, so I can't divulge more details).
I install the app with on our target device (which is running 2.3.4 Gingerbread, if that is relevant). The library.cfg
file appears correctly.
I edit the library.cfg
file to include a new setting value.
I then install the app again with the same signing config, but an incremented version name/code. The new APK includes the new settings in the asset file.
If I only install the app, the changes to library.cfg
are not reflected by the copy of the file at /data/data/com.myapp.package/library/library.cfg
. The file is the same as in the original install.
If I uninstall the app and then install the second build of the app with the updated config file, /data/data/com.myapp.package/library/library.cfg
contains the added values.
Why isn't the file updated when I upgrade the app rather than uninstalling/reinstalling? What do I have to do to ensure that the file is updated during upgrade?
Open the file with Context.getAssets()
on each startup of the app, when upgrade the app, first launch it and after that check if the file has change.
Its seems that until you access the file, it is not extracted from the apk to /data/data/<your-package>/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With