Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download and replace Android resource files

My application will have some customisation for each company that uses it. Up until now, I have been loading images and strings from resource files. The idea is that the default resources will be distributed with the application and company specific resources will be loaded from our server after they click on a link from an email to launch the initialisation intent. Does anyone know how to replace resource files? I would really like to keep using resource files to avoid rewriting a lot of code/XML.

I would distribute the application from our own server, rather than through the app store, so that we could have one version per company, but unfortunately this will give quite nasty security warnings that would concern our customers.

like image 622
Casebash Avatar asked May 13 '10 00:05

Casebash


2 Answers

Does anyone know how to replace resource files?

It is not possible, except by deploying an updated APK. APKs are digitally signed and cannot be modified at runtime.

like image 171
CommonsWare Avatar answered Sep 25 '22 17:09

CommonsWare


No it is not possible, but here is what you can do instead... Copy your images etc in the Assets folder.. From the assets folder , copy them at runtime in the Application dir.. ie data/data/yourapppackage/yourresourcefolder Use the images etc from the runtime folder.. Ie In code say,.. imageView.setBackgroundDrawable(data/data/apppackagename/download/themename/resourcename)... Now when you download your resources from a runtime path , keep an XML file with key names and path for the image as key value pairs.. Have approprite Enums for that in code and store the image paths in HashMap at runtime..

like image 20
Alok Kulkarni Avatar answered Sep 24 '22 17:09

Alok Kulkarni