views:

202

answers:

3

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.

+3  A: 

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.

CommonsWare
A: 

Yes its possible .. 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(runtimepath)... 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..

Alok
So, basically, you are suggesting that instead of using Android's [resource](http://developer.android.com/guide/topics/resources/resources-i18n.html) system, to just use their file storage instead?
Casebash
I would upvote this answer, except that your first sentence says "Yes its possible", when it actually can't be done and this is just a work around. If you correct this, then I will upvote it
Casebash
@Casebash i dint get by what you mean by "If you correct this"..So basically you cannot replace the drawable folder ie resource folder , but can refer to images taken from runtime path .So by its possible i did not mean , replacing the images from resource folder but solution for replacing the images at runtime is possible provided you supply the runtime path.. Sorry for all the inconvenience caused. :)Thanks,Alok.
Alok
@Alok: Your answer would be clearer if it said something like: "No it is not possible, but here is what you can do instead."
Casebash
@Casebash :) :) will take care next time :)
Alok
A: 

Yes.That works fine. I am using themes in my app and server sends me images according to theme which user selects and i apply them at runtime. apparently i am having a few leaks in memory, but not substantiaal which i need to solve.I am working on the same lines as you are.

Alok
@Alok, this should actually be a comment on your original answer rather than another answer. You don't have enough reputation to comment on other peoples questions and answers yet, but you should be able to comment on your own. Please delete this answer and repost it as a comment.
Casebash
HI,Sorry for a seperate answer , i didnt know the rules here.But i dont see how i can delete the answer. According to what you say , if its a work around , its working fine for me in Android 1.5 . Do you see a problem with this solution in further SDKs ?
Alok