Download and replace Android resource files

My application will have some configuration for each company that uses it. So far I have been loading images and strings from resource files. The idea is that by default the resources will be distributed with the application, and the resources for a particular company will be downloaded from our server after they click on the link from the email to start the initialization intent. Does anyone know how to replace resource files? I would really like to continue to use resource files to avoid overwriting a lot of code / XML.

I would distribute the application from our own server, and not through the application store, so that we can have one version for one company, but, unfortunately, this will give rather unpleasant security warnings that will affect our customers.

+6
android resources
source share
2 answers

Does anyone know how to replace resource files?

This is not possible, except for deploying the updated APK. APKs are digitally signed and cannot be changed at run time.

+10
source share

No, this is not possible, but here is what you can do ... Copy your images, etc. to the Assets folder. From the Resources folder, copy them at runtime in the application directory, i.e. data / data / yourapppackage / yourresourcefolder Use images, etc. From the runtime folder. Those. they say in the code .. imageView.setBackgroundDrawable(data/data/apppackagename/download/themename/resourcename) ... Now that you are loading your resources from the execution path, store the XML file with key names and an outline for the image as key pairs . Make sure this listing is in the code and save the image paths in the HashMap at runtime.

+7
source share

All Articles